装置对应版本python

如果零碎装置的python版本和我的项目所需的版本不统一,须要手动下载python二进制包编译装置

获取指定版本python,网址

https://registry.npmmirror.com/binary.html?path=python/

比方当初装置python3.6.15版本,上面命令参数须要根据具体python版本而扭转

创立文件夹

$ 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到解压文件夹,会存在一个配置文件configure

$ 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

--enable-optimizations容许进行优化,--prefix指定装置目录

编译,装置

$ sudo make all$ sudo make install

上述步骤执行实现之后,/usr/local/python3/bin会装置好对应版本的pythonpip可执行文件,当初创立对应的软链接

$ 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 -Vpip 18.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6)

留神点

因为python的地位是/usr/local/python3,所以在pip装置实现一些库生成的二进制包的可执行文件门路地位是/usr/local/python3/bin/

比方装置实现celeryuwsgi,所以执行的时候须要执行

/usr/local/python3/bin/celery或者/usr/local/python3/bin/uwsgi

psycopg2或者psycopy2-binarypip依赖谬误

报错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

lxmlpip依赖谬误

报错Error: Please make sure the libxml2 and libxslt development packages are installed

执行apt install libxml2 libxslt1-dev

pillowpip依赖谬误

报错如下

    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

顺着文档上来发现有很多二进制依赖,留神到zliblibjpeg库是必要的

去查看python pillowarm架构的Dockerfile查看须要装置到包

目前只须要依照必要的包即可解决问题

$ apt install libjpeg8-dev zlib1g-dev

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 connection

或者报错如下

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.8nameserver 8.8.4.4

之后重启docker

$ sudo systemctl restart docker

docker拉取镜像报错非法tar头部

报错如下

failed 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

解决方案二,参考docker官网文档,配置对应的环境变量

$ vim /usr/lib/systemd/system/docker.service# 在Service的单元上面,减少这一行[Service]Environment="MOBY_DISABLE_PIGZ=true"

git clone域名解析报错

报错输入Could not resolve host: gitee.com

麒麟零碎的git感觉压根就不反对域名解析,首先查看gitee.comIP

$ nslookup github.comServer:         223.5.5.5Address:        223.5.5.5#53Non-authoritative answer:Name:   gitee.comAddress: 212.64.63.190

查问不到的话须要显示指定dns地址

$ nslookup gitlab.bolean.com 8.8.8.8

最初把对应的IP解析写入/etc/hosts

212.64.63.190 gitee.com

git clonegnutls报错

报错输入gnutls_handshake() failed: 在 push 函数中出错

这个解决比拟麻烦,须要把gnutls替换为openssl,只能从源码构建git解决

装置一些前置依赖

$ apt-get install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

查看零碎以后git版本

$ git versiongit version 2.25.1

保险起见获取一个雷同版本的git

获取git的网站地址kernel.orggit镜像

$ 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

这个时候默认是应用openssl的(这个不分明在别的版本是否是这样的)

执行之前先执行如下命令,查看输入的提示信息当中是否有这一行

$ ./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

最初删除零碎自带的git,创立一个软链接指向编译生成的git

$ sudo mv /usr/bin/git /usr/bin/git.back$ sudo ln -s /usr/local/git/bin/git /usr/bin/git

参考浏览

docker daemon文档

python pillowarm架构的Dockerfile