为什么你需要升级 pip ?
[itamarst@blake dev]$ docker run -it ubuntu:18.04
root@1a43d55f0524:/# apt-get update
...
root@1a43d55f0524:/# apt-get install --no-install-recommends python3 python3-pip
...
root@1a43d55f0524:/# pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
root@1a43d55f0524:/# pip3 install cryptography
Collecting cryptography
Downloading https://files.pythonhosted.org/packages/fa/2d/2154d8cb773064570f48ec0b60258a4522490fcb115a6c7c9423482ca993/cryptography-3.4.6.tar.gz (546kB)
100% |################################| 552kB 1.4MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-6jesygn0/cryptography/
setuptools
,编译器和Python开发工具链,这将起作用,但非常慢。package
。PyArrow
也会发生相同的问题,例如:root@1a43d55f0524:/# pip3 install pyarrow
Collecting pyarrow
Downloading https://files.pythonhosted.org/packages/62/d3/a482d8a4039bf931ed6388308f0cc0541d0cab46f0bbff7c897a74f1c576/pyarrow-3.0.0.tar.gz (682kB)
100% |################################| 686kB 1.1MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-heq6zwd7/pyarrow/
Fil
,Python内存分析器https://pythonspeed.com/products/filmemoryprofiler/
。root@1a43d55f0524:/# pip3 install filprofiler
Collecting filprofiler
Downloading https://files.pythonhosted.org/packages/e3/a2/843e7b5f1aba27effb0146c7e564e2592bfc9344a8c8ef0d55245bd47508/filprofiler-0.7.2-cp36-cp36m-manylinux1_x86_64.whl (565kB)
100% |################################| 573kB 1.8MB/s
Installing collected packages: filprofiler
Successfully installed filprofiler-0.7.2
Fil
的PyPI
页面(https://pypi.org/project/filprofiler/
)外,您都会看到``0.7.2`的版本很旧。在撰写本文时,Fil的最新版本是0.14.1。pip
和manylinux
轮子NumPy
到Cryptography
的许多软件包都要求在C / C ++ / Cython / Rust / etc中编译一些代码。为了节省您从头开始编译所有内容的需要,维护人员可以将代码的编译版本(“ wheels”)上载到Python Package Index。如果pip碰到适用于您的特定版本的Python和操作系统版本的轮子,它将下载它而不是源代码。manylinux1
,manylinux2010
和manylinux2014
。您可以在下载的轮子的文件名中看到正在使用哪个变体。manylinux2010
,当然也不支持manylinux2014
。Ubuntu 18.04中的pip太旧了,因此它只了解manylinux1
。这解释了我们看到的两个问题:PyArrow 3.0.0
的可用文件列表(https://pypi.org/project/pyarrow/3.0.0/#files
),您会看到只有很多linux2010
和linux2014
的轮子。因此,pip会回退到需要编译的源代码包。Fil
的PyPI文件(https://pypi.org/project/filprofiler/0.14.1/#files
),则会看到有manylinux2010
轮子,而根本没有源程序包;因为从源代码构建有点棘手,所以我只分发编译后的程序包。这意味着pip会继续使用该软件包的较早版本,直到找到具有manylinux1
轮子的软件包为止。pip install --upgrade pip
来每天进行一次升级。pip install
来修改系统软件包。$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python3 get-pip.py
pip install --upgrade pip
升级其pip:root@1a43d55f0524:/# python3 -m venv myvenv
root@1a43d55f0524:/# . myvenv/bin/activate
(myvenv) root@1a43d55f0524:/# pip --version
pip 9.0.1 from /myvenv/lib/python3.6/site-packages (python 3.6)
(myvenv) root@1a43d55f0524:/# pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/fe/ef/60d7ba03b5c442309ef42e7d69959f73aacccd0d86008362a681c4698e83/pip-21.0.1-py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-21.0.1
pip
,我们可以轻松地安装最新版本的cryptography
和filprofiler
:(myvenv) root@1a43d55f0524:/# pip install cryptography filprofiler
Collecting cryptography
Downloading cryptography-3.4.6-cp36-abi3-manylinux2014_x86_64.whl (3.2 MB)
|################################| 3.2 MB 4.5 MB/s
...
Installing collected packages: pycparser, threadpoolctl, cffi, filprofiler, cryptography
Successfully installed cffi-1.14.5 cryptography-3.4.6 filprofiler-0.14.1 pycparser-2.20 threadpoolctl-2.1.0
cryptography
的manylinux2014
软件包。glibc
)。您可以使用ldd
实用工具查看可执行文件或共享库链接到哪些库:root@1a43d55f0524:/# cd myenv/lib/python3.6/site-packages
root@1a43d55f0524:/# ldd cryptography/hazmat/bindings/_openssl.abi3.so
linux-vdso.so.1 (0x00007ffdbea7b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fba7b1bf000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fba7adce000)
/lib64/ld-linux-x86-64.so.2 (0x00007fba7b7b0000)
/lib/x86_64-linux-gnu/libc.so.6
,即glibc
。glibc
的较新版本编译代码,它可能不需要在旧版本提供新的API或符号。这意味着你的代码不会在旧的Linux发行版上运行。Conda
通过针对旧版本的glibc
头文件来编译所有的包;基本上在广泛的Linux发行版它有一个自定义编译安装设计工作。glibc
来解决这个问题。因为它是针对旧版本编译的,它会与任何新版本兼容工作。manylinux1
包建在CentOS 5。manylinux2010
包建在CentOS 6。manylinux2014
软件包都建立在CentOS 7上。
PEP-571
和PEP-599
。Dockerfile
,请确保升级pip。否则,你就会有一个更难的时间安装软件包。更多阅读
特别推荐
点击下方阅读原文加入社区会员
评论