Python版本:python3.7.6 对应的各种模块
Traceback (most recent call last):
File "casbrun.py", line 12, in
import common
File "./common/common.py", line 3, in
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
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
from aoeweb import AOEWeb
File "./server/aoeweb.py", line 6, in
import requests
ModuleNotFoundError: No module named 'requests'
pip3 install requests
Traceback (most recent call last):
File "DB2OPE.py", line 2, in
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
$pip3 install pandas==0.23.4
File "casbrun.py", line 13, in
from aoeweb import AOEWeb
File "./server/aoeweb.py", line 8, in
from getfile import Getfile
File "./common/getfile.py", line 8, in
import requests_pkcs12
ModuleNotFoundError: No module named 'requests_pkcs12'
pip3 install requests_pkcs12
Traceback (most recent call last):
File "casbrun.py", line 13, in
from aoeweb import AOEWeb
File "./server/aoeweb.py", line 6, in
import requests
File "/usr/local/lib/python3.7/site-packages/requests/__init__.py", line 43, in
import urllib3
File "/usr/local/lib/python3.7/site-packages/urllib3/__init__.py", line 42, in
"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
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 /usr/bin/pip3
其中pip3不可用时解决
[root@loaclhost bin]# pip3
-bash: /usr/local/bin/pip3: No such file or directory
[root@loaclhost bin]# cp /usr/local/python3/bin/pip3 /usr/local/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)"
有时候我们在liunx上想修改查看python的包路径可以试试以下命令
from distutils.sysconfig import get_python_lib
print(get_python_lib())