pra*_*rat 4 python pip virtualenv python-3.x
我正在尝试在非互联网机器上安装几个 python 包。出现错误为
Could not find a version that satisfies the requirement cryptography==3.4.7 (from -r requirements.txt (line 14)) (from versions: )
No matching distribution found for cryptography==3.4.7 (from -r requirements.txt (line 14))
Run Code Online (Sandbox Code Playgroud)
我下载了在线系统中的所有软件包,并将requirements.txt软件包文件夹移动并下载到离线系统,并尝试使用以下命令在其中安装软件包,
pip3.6 install --no-index --find-links="./tranferred_packages" -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
我遵循的步骤 -
virtualenv使用pip在线安装:pip install virtualenv --user
Run Code Online (Sandbox Code Playgroud)
virtualenv并获取它的来源python -m virtualenv myenv
cd myenv
source bin/activate
Run Code Online (Sandbox Code Playgroud)
pip3 install pkgname
Run Code Online (Sandbox Code Playgroud)
pip freeze > requirements.txt
Run Code Online (Sandbox Code Playgroud)
pip download -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
requirements.txt并下载到离线系统并尝试使用安装 pkgs 在那里pip install --no-index --find-links="./tranferred_packages" -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
详细错误是
Collecting cryptography==3.4.7 (from -r requirements.txt (line 14))
0 location(s) to search for versions of cryptography:
Could not find a version that satisfies the requirement cryptography==3.4.7 (from -r requirements.txt (line 14)) (from versions: )
Cleaning up...
Removing source in /tmp/pip-build-beg7uvpz/aws-requests-auth
Removing source in /tmp/pip-build-beg7uvpz/blist
Removing source in /tmp/pip-build-beg7uvpz/chardet2
No matching distribution found for cryptography==3.4.7 (from -r requirements.txt (line 14))
Exception information:
Traceback (most recent call last):
File "/root/venv/lib64/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/root/venv/lib64/python3.6/site-packages/pip/commands/install.py", line 346, in run
requirement_set.prepare_files(finder)
File "/root/venv/lib64/python3.6/site-packages/pip/req/req_set.py", line 381, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/root/venv/lib64/python3.6/site-packages/pip/req/req_set.py", line 557, in _prepare_file
require_hashes
File "/root/venv/lib64/python3.6/site-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/root/venv/lib64/python3.6/site-packages/pip/index.py", line 514, in find_requirement
'No matching distribution found for %s' % req
pip.exceptions.DistributionNotFound: No matching distribution found for cryptography==3.4.7 (from -r requirements.txt (line 14))
Run Code Online (Sandbox Code Playgroud)
我已经在文件夹中cryptography提到requirements.txt并cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl存在tranferred_packages。
cat requirements.txt | grep cryptography
cryptography==3.4.7
(venv) [root@ip-172-35-10-19 venv]# ls -l tranferred_packages/cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl
-rwxr-xr-x. 1 root root 3181242 Apr 27 15:05 tranferred_packages/cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl
(venv) [root@ip-172-35-10-19 venv]#
Run Code Online (Sandbox Code Playgroud)
其他包的输出没有给出错误,
Collecting certifi==2020.4.5.1 (from -r requirements.txt (line 7))
0 location(s) to search for versions of certifi:
Found link file:///root/venv/tranferred_packages/certifi-2020.4.5.1-py2.py3-none-any.whl, version: 2020.4.5.1
Local files found: /root/venv/tranferred_packages/certifi-2020.4.5.1-py2.py3-none-any.whl
Using version 2020.4.5.1 (newest of versions: 2020.4.5.1)
Run Code Online (Sandbox Code Playgroud)
我可以在创建时安装相同的内容virtualenv,但在创建时不能安装venv。
使用以下命令创建virtualenv ,
pip3 install virtualenv --user
Run Code Online (Sandbox Code Playgroud)
输出pip3 list
# pip3 list |grep cryptography
cryptography 3.4.7
Run Code Online (Sandbox Code Playgroud)
在这个 virtualenv 中,python 和 pip 版本是,
python python2.7 python3.6 python3.6m python3.6m-x86_64-config
python2 python3 python3.6-config python3.6m-config python3-config
# python -V
Python 3.6.8
# python3.6 -V
Python 3.6.8
pip pip3 pip-3 pip-3.6 pip3.6
# pip-3.6 -V
pip 21.0.1 from /root/oldenv/lib/python3.6/site-packages/pip (python 3.6)
Run Code Online (Sandbox Code Playgroud)
以上所有 pip 显示版本为,pip 21.0.1除了pip-3其中显示版本为,
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
创建 virtualenv 后默认安装了以下三个模块
pip 21.0.1
setuptools 56.0.0
wheel 0.34.2
Run Code Online (Sandbox Code Playgroud)
使用以下命令创建venv ,
# python3.6 -m venv devenv
Run Code Online (Sandbox Code Playgroud)
创建venv后默认安装以下两个模块,
pip (9.0.3)
setuptools (39.2.0)
Run Code Online (Sandbox Code Playgroud)
系统范围的 python 和 pip 版本
python python2.7 python3.6 python3.6m python3.6m-x86_64-config
python2 python3 python3.6-config python3.6m-config python3-config
# python --version
Python 2.7.5
# python3.6 --version
Python 3.6.8
pip3 pip-3 pip-3.6 pip3.6
# pip3.6 -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
Run Code Online (Sandbox Code Playgroud)
其他详情 -
RHEL 7.8(麦坡)
内核 - 3.10.0-1127.el7.x86_64
有人能说出是什么导致了问题吗?
谢谢,
pip-9.0.3使用命令从pip-21.1(pip-21.1-py3-none-any.whl)升级后问题得到解决python3 -m pip install --upgrade pip-21.1-py3-none-any.whl。