python + 升级密码 pkg 后没有名为 cryptography.fernet 的模块
python + No module named cryptography.fernet after upgrade cryptography pkg
我们更新了一些 python pkg 和模块
其中一个是 pkg cryptography
我们将密码系统从版本 cryptography (1.7.1)
更新到 cryptography (2.9.2)
但是当我们访问 python shell 时,我们得到 ImportError: No module named cryptography.fernet
尽管安装了密码系统
pip list |grep cryptography
cryptography (2.9.2)
来自 python shell
python
Python 2.7.5 (default, Sep 12 2018, 05:31:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.fernet import Fernet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cryptography.fernet
注意 - 在以前的版本 cryptography (1.7.1)
上,一切正常
那么模块可能有什么问题?
注意同样的问题来自 python 脚本
import sys
import os
import base64
from cryptography.fernet import Fernet
.
.
.
安装以下 rpm 文件解决了问题
yum localinstall python2-cryptography-1.7.2-2.el7.x86_64.rpm
Loaded plugins: langpacks
Configuration
Examining python2-cryptography-1.7.2-2.el7.x86_64.rpm: python2-cryptography-1.7.2-2.el7.x86_64
Marking python2-cryptography-1.7.2-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
python2-cryptography x86_64 1.7.2-2.el7 /python2-cryptography-1.7.2-2.el7.x86_64 2.6 M
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total size: 2.6 M
Installed size: 2.6 M
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.2020-06-04.09-55.SDc8o9.yumtx
[root@master02 TEST1]# yum localinstall python2-cryptography-1.7.2-2.el7.x86_64.rpm
Loaded plugins: langpacks
Repository HDP-2.6-repo-1 is listed more than once in the configuration
Repository HDP-UTILS-1.1.0.22-repo-1 is listed more than once in the configuration
Examining python2-cryptography-1.7.2-2.el7.x86_64.rpm: python2-cryptography-1.7.2-2.el7.x86_64
Marking python2-cryptography-1.7.2-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
python2-cryptography x86_64 1.7.2-2.el7 /python2-cryptography-1.7.2-2.el7.x86_64 2.6 M
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total size: 2.6 M
Installed size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python2-cryptography-1.7.2-2.el7.x86_64 1/1
Verifying : python2-cryptography-1.7.2-2.el7.x86_64 1/1
Installed:
python2-cryptography.x86_64 0:1.7.2-2.el7
Complete!
我们更新了一些 python pkg 和模块
其中一个是 pkg cryptography
我们将密码系统从版本 cryptography (1.7.1)
更新到 cryptography (2.9.2)
但是当我们访问 python shell 时,我们得到 ImportError: No module named cryptography.fernet
尽管安装了密码系统
pip list |grep cryptography
cryptography (2.9.2)
来自 python shell
python
Python 2.7.5 (default, Sep 12 2018, 05:31:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.fernet import Fernet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cryptography.fernet
注意 - 在以前的版本 cryptography (1.7.1)
上,一切正常
那么模块可能有什么问题?
注意同样的问题来自 python 脚本
import sys
import os
import base64
from cryptography.fernet import Fernet
.
.
.
安装以下 rpm 文件解决了问题
yum localinstall python2-cryptography-1.7.2-2.el7.x86_64.rpm
Loaded plugins: langpacks
Configuration
Examining python2-cryptography-1.7.2-2.el7.x86_64.rpm: python2-cryptography-1.7.2-2.el7.x86_64
Marking python2-cryptography-1.7.2-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
python2-cryptography x86_64 1.7.2-2.el7 /python2-cryptography-1.7.2-2.el7.x86_64 2.6 M
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total size: 2.6 M
Installed size: 2.6 M
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.2020-06-04.09-55.SDc8o9.yumtx
[root@master02 TEST1]# yum localinstall python2-cryptography-1.7.2-2.el7.x86_64.rpm
Loaded plugins: langpacks
Repository HDP-2.6-repo-1 is listed more than once in the configuration
Repository HDP-UTILS-1.1.0.22-repo-1 is listed more than once in the configuration
Examining python2-cryptography-1.7.2-2.el7.x86_64.rpm: python2-cryptography-1.7.2-2.el7.x86_64
Marking python2-cryptography-1.7.2-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package python2-cryptography.x86_64 0:1.7.2-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
python2-cryptography x86_64 1.7.2-2.el7 /python2-cryptography-1.7.2-2.el7.x86_64 2.6 M
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total size: 2.6 M
Installed size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python2-cryptography-1.7.2-2.el7.x86_64 1/1
Verifying : python2-cryptography-1.7.2-2.el7.x86_64 1/1
Installed:
python2-cryptography.x86_64 0:1.7.2-2.el7
Complete!