安装对应版本python
如果系统安装的python版本和项目所需的版本不一致,需要手动下载python二进制包编译安装
获取指定版本python,网址
https://registry.npmmirror.com/binary.html?path=python/https://registry.npmmirror.com/binary.html?path=python/比如现在安装python3.6.15版本,下面命令参数需要依据具体python版本而改变
创建文件夹
$ sudo mkdir /usr/local/python3$ sudo mkdir /usr/local/python3获取对应版本的压缩包文件
$ cd /usr/local/python3
$ sudo wget https://cdn.npmmirror.com/binaries/python/3.6.15/Python-3.6.15.tar.xz$ cd /usr/local/python3
$ sudo wget https://cdn.npmmirror.com/binaries/python/3.6.15/Python-3.6.15.tar.xz解压压缩包之后cd到解压文件夹,会存在一个配置文件configure
$ sudo tar -xvf Python-3.6.15.tar.xz$ sudo tar -xvf Python-3.6.15.tar.xz执行配置文件,该操作会生成Makefile文件
$ cd /usr/local/python3/Python-3.6.15
$ sudo ./configure --enable-optimizations --prefix=/usr/local/python3$ cd /usr/local/python3/Python-3.6.15
$ sudo ./configure --enable-optimizations --prefix=/usr/local/python3--enable-optimizations允许进行优化,--prefix指定安装目录
编译,安装
$ sudo make all
$ sudo make install$ sudo make all
$ sudo make install上述步骤执行完成之后,/usr/local/python3/bin会安装好对应版本的python和pip可执行文件,现在创建对应的软链接
$ sudo ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3.6
$ sudo ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3.6$ sudo ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3.6
$ sudo ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3.6验证安装结果,可以看到pip3.6指向的python版本以及对应位置
$ pip3.6 -V
pip 18.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6)$ pip3.6 -V
pip 18.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6)注意点
由于python的位置是/usr/local/python3,所以在pip安装完成一些库生成的二进制包的可执行文件路径位置是/usr/local/python3/bin/
比如安装完成celery和uwsgi,所以执行的时候需要执行
/usr/local/python3/bin/celery或者/usr/local/python3/bin/uwsgi
docker拉取镜像超时
docker pull redis报错如下
Head https://registry-1.docker.io/v2/library/redis/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fredis%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connectionHead https://registry-1.docker.io/v2/library/redis/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fredis%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection或者报错如下
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)则需要修改域名解析文件/etc/resolv.conf,直接使用vim编辑
nameserver 8.8.8.8
nameserver 8.8.4.4nameserver 8.8.8.8
nameserver 8.8.4.4之后重启docker
$ sudo systemctl restart docker$ sudo systemctl restart dockerdocker拉取镜像报错非法tar头部
报错如下
failed to register layer: ApplyLayer exit status 1 stdout: stderr: archive/tar: invalid tar headerfailed to register layer: ApplyLayer exit status 1 stdout: stderr: archive/tar: invalid tar header该错误产生原因是使用unpigz解压缩docker镜像层导致的
解决方案一,移动unpigz可执行文件位置使其不解压
$ mv /usr/bin/unpigz /usr/bin/unpigz.bak$ mv /usr/bin/unpigz /usr/bin/unpigz.bak解决方案二,参考docker官方文档,配置对应的环境变量
$ vim /usr/lib/systemd/system/docker.service
# 在Service的单元下面,增加这一行
[Service]
Environment="MOBY_DISABLE_PIGZ=true"$ vim /usr/lib/systemd/system/docker.service
# 在Service的单元下面,增加这一行
[Service]
Environment="MOBY_DISABLE_PIGZ=true"git clone域名解析报错
报错输出Could not resolve host: gitee.com
麒麟系统的git感觉压根就不支持域名解析,首先查看gitee.com的IP
$ nslookup gitee.com
Server: 223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
gitee.com canonical name = aoufnebg.dayugslb.com.
Name: aoufnebg.dayugslb.com
Address: 212.64.63.215
Name: aoufnebg.dayugslb.com
Address: 212.64.63.190$ nslookup gitee.com
Server: 223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
gitee.com canonical name = aoufnebg.dayugslb.com.
Name: aoufnebg.dayugslb.com
Address: 212.64.63.215
Name: aoufnebg.dayugslb.com
Address: 212.64.63.190查询不到的话需要显示指定dns地址
$ nslookup gitee.com 8.8.8.8$ nslookup gitee.com 8.8.8.8最后把对应的IP解析写入/etc/hosts
212.64.63.190 gitee.com212.64.63.190 gitee.comgit clone的gnutls报错
报错输出gnutls_handshake() failed: 在 push 函数中出错
这个解决比较麻烦,需要把gnutls替换为openssl,只能从源码构建git解决
安装一些前置依赖
$ apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev$ apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev查看系统当前git版本
$ git version
git version 2.25.1$ git version
git version 2.25.1保险起见获取一个相同版本的git包
获取git的网站地址kernel.org,git镜像
$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.1.tar.gz$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.1.tar.gz解压编译
$ tar -zxf git-2.25.1.tar.gz
$ cd git-2.25.1
$ make configure$ tar -zxf git-2.25.1.tar.gz
$ cd git-2.25.1
$ make configure这个时候默认是使用openssl的(这个不清楚在别的版本是否是这样的)
执行之前先执行如下命令,查看输出的提示信息当中是否有这一行
$ ./configure --help
...
--with-openssl use OpenSSL library (default is YES)
ARG can be prefix for openssl library and headers
...$ ./configure --help
...
--with-openssl use OpenSSL library (default is YES)
ARG can be prefix for openssl library and headers
...编译安装
$ ./configure --prefix=/usr/local/git
$ make
$ make install$ ./configure --prefix=/usr/local/git
$ make
$ make install最后删除系统自带的git,创建一个软链接指向编译生成的git
$ sudo mv /usr/bin/git /usr/bin/git.back
$ sudo ln -s /usr/local/git/bin/git /usr/bin/git$ sudo mv /usr/bin/git /usr/bin/git.back
$ sudo ln -s /usr/local/git/bin/git /usr/bin/gitpsycopg2或者psycopy2-binary的pip依赖错误
报错Error: pg_config executable not found.
pg_config是位于postgresql-devel包当中在
Debian/Ubuntu系当中需要安装libpq-dev在
Centos/Fedora/Cygwin/Babun/Redhat系的系统当中需要libpq-devel麒麟系统执行
apt install libpq-dev
lxml的pip依赖错误
报错Error: Please make sure the libxml2 and libxslt development packages are installed
执行apt install libxml2 libxslt1-dev
pillow的pip依赖错误
报错如下
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html顺着文档下去发现有很多二进制依赖,注意到zlib和libjpeg库是必要的
去查看python pillow的arm架构的Dockerfile查看需要安装到包
目前只需要按照必要的包即可解决问题
$ apt install libjpeg8-dev zlib1g-dev$ apt install libjpeg8-dev zlib1g-dev