Python版本:python3.7.6 对应的各种模块
Traceback (most recent call last):
? File "casbrun.py", line 12, in <module>
? ? import common
? File "./common/common.py", line 3, in <module>
? ? from Crypto.PublicKey import RSA
ModuleNotFoundError: No module named 'Crypto'
#用到的 from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_v1_5 as PKCS1_cipher
安装:pip install?pycryptodome
或pip3 install?pycryptodome
Traceback (most recent call last):
? File "casbrun.py", line 13, in <module>
? ? from aoeweb import AOEWeb
原因:引用其他文件夹的py时,需要先加载文件夹
import sys sys.path.append('./server') #server为文件夹,为服务py sys.path.append('./common') #common为文件夹,为工具pyimport common from aoeweb import AOEWeb
pip3 install ibm-db==3.0.1
Traceback (most recent call last):
? File "casbrun.py", line 13, in <module>
? ? from aoeweb import AOEWeb
? File "./server/aoeweb.py", line 6, in <module>
? ? import requests
ModuleNotFoundError: No module named 'requests'
pip3 install?requests
Traceback (most recent call last):
? File "casbrun.py", line 13, in <module>
? ? from aoeweb import AOEWeb
? File "./server/aoeweb.py", line 6, in <module>
? ? import requests
? File "/usr/local/lib/python3.7/site-packages/requests/__init__.py", line 43, in <module>
? ? import urllib3
? File "/usr/local/lib/python3.7/site-packages/urllib3/__init__.py", line 42, in <module>
? ? "urllib3 v2.0 only supports OpenSSL 1.1.1+, currently "
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips ?26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
原因:提示requests用到的openssl版本是openssl1.1.1 ,和当前系统的openssl版本不一致
1、先查看openssl版本:openssl version -a
2、centos7升级openssl到openssl1.1.1
参考:Centos7升级openssl到openssl1.1.1
Centos7升级openssl到openssl1.1.1-CSDN博客
#删除软链接和重新建立软链接
rm /usr/bin/openssl
ln -s /usr/local/openssl/bin/openssl /usr/bin/opensslecho "/usr/local/openssl/lib/" >> /etc/ld.so.conf
ldconfig -v#加载环境变量
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
$source /etc/profile
$echo $LD_LIBRARY_PATH
3、升级python3的openssl
如果你使用的是源代码包,可以通过在运行./configure命令时传递–with-openssl参数,并指定新版本的OpenSSL库所在的路径来配置Python的编译选项。
$cd?cd Python-3.7.6
#编译
$./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
看到:checking for openssl/ssl.h in /usr/local/openssl... yes
? ? ? ? ? ?checking whether compiling and linking against OpenSSL works... yes$make clean
$make & make install
#备注,如果有问题就make之后再make install
#加入python3的软链接
rm /usr/bin/python3
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
参考:https://codeleading.com/article/19232024257/
参考:https://blog.csdn.net/inthat/article/details/131365519
https://blog.csdn.net/weixin_63133658/article/details/134380096
4、检查 Python 的?ssl
?模块版本:
python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"