繁体   English   中英

无法在 python 的 venv 中安装 cryptography==3.4.7

[英]unable to install cryptography==3.4.7 in venv in python

我正在尝试在非互联网机器上安装几个 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))

我下载了在线系统中的所有软件包并将requirements.txt和下载的软件包文件夹移动到离线系统并尝试使用以下命令在那里安装软件包,

pip3.6 install --no-index --find-links="./tranferred_packages" -r requirements.txt

我遵循的步骤 -

  1. 使用 pip 在线安装virtualenv
pip install virtualenv --user

  1. 创建virtualenv并获取它
python -m virtualenv myenv
cd myenv 
source bin/activate
  1. 使用安装的包
pip3 install pkgname
  1. 然后做了
pip freeze > requirements.txt
  1. 使用下载 pkgs 到一个文件夹
pip download -r requirements.txt
  1. requirements.txt和下载的 pkgs 文件夹移动到离线系统,并尝试在那里安装 pkgs
pip install --no-index --find-links="./tranferred_packages" -r requirements.txt

详细错误是

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))

我在requirements.txtcryptography cryptography-3.4.7-cp36-abi3-manylinux2014_x86_64.whl中提到了 tranferred_pa 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]# 

Output 的其他包没有给出错误,

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)

我可以在创建virtualenv时安装相同的东西,但在创建venv时不能。

使用以下命令创建了 virtualenv

pip3 install virtualenv --user

pip3 pip3 list的 Output

# pip3 list |grep cryptography
cryptography          3.4.7

在这个 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)

以上 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

使用以下命令创建了 venv

# python3.6 -m venv devenv 

创建venv后默认安装以下两个模块,

pip (9.0.3)
setuptools (39.2.0)

系统范围 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)

其他详情 -

RHEL 7.8(迈坡)
Kernel - 3.10.0-1127.el7.x86_64

有人可以说是什么导致了问题吗?

谢谢,

使用python3 -m pip install --upgrade pip-21.1-py3-none-any.whl命令从pip-9.0.3升级到pip-21.1 (pip-21.1-py3-none-any.whl) 后问题得到解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM