【非抄袭】AttributeError module ‘lib‘ has no attribute OpenSSL_add

网络做法

翻了下帖子,全部是降级,openssl和crypto两个库

# ImportError: cannot import name 'SSLv3_METHOD' from 'OpenSSL.SSL'
pip3 install pyopenssl==22.0.0

# AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
pip3 install cryptography==38.0.4

来自:https://stackoverflow.com/questions/73859249/attributeerror-module-openssl-ssl-has-no-attribute-sslv3-method,其他的基本上都是这个抄的(或者说转载的)。

我试了。两个都已经requirement already satisfied了,还是一直出这个错。
又看到说,如果不行,再继续降级。我随即试了cryptography==38.0.4到38.0.1。

没卵用

那我想,既然是version不匹配,那我就直接全部升级成最新的吧。
于是

pip install pyopenssl==lastest
ERROR: Could not find a version that satisfies the requirement pyopenssl==lastest (from versions: 0.6, 0.7, 0.8, 0.9, 0.10, 0.12, 0.13, 0.13.1, 0.14, 0.15, 0.15.1, 16.0.0, 16.1.0, 16.2.0, 17.0.0, 17.1.0, 17.2.0, 17.3.0, 17.4.0, 17.5.0, 18.0.0, 19.0.0, 19.1.0, 20.0.0, 20.0.1, 21.0.0, 22.0.0, 22.1.0, 23.0.0, 23.1.0, 23.1.1)
ERROR: No matching distribution found for pyopenssl==lastest
pip install cryptography==lastest
ERROR: Could not find a version that satisfies the requirement cryptography==lastest (from versions: 0.1, 0.2, 0.2.1, 0.2.2, 0.3, 0.4, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.9, 0.9.1, 0.9.2, 0.9.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.1.1, 1.1.2, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.7, 1.7.1, 1.7.2, 1.8, 1.8.1, 1.8.2, 1.9, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2, 2.2.1, 2.2.2, 2.3, 2.3.1, 2.4, 2.4.1, 2.4.2, 2.5, 2.6, 2.6.1, 2.7, 2.8, 2.9, 2.9.1, 2.9.2, 3.0, 3.1, 3.1.1, 3.2, 3.2.1, 3.3, 3.3.1, 3.3.2, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 35.0.0, 36.0.0, 36.0.1, 36.0.2, 37.0.0, 37.0.1, 37.0.2, 37.0.3, 37.0.4, 38.0.0, 38.0.1, 38.0.2, 38.0.3, 38.0.4, 39.0.0, 39.0.1, 39.0.2, 40.0.0, 40.0.1, 40.0.2)
ERROR: No matching distribution found for cryptography==lastest

找了下他们最新的,然后分别pip install了最新的。没用!还是 出现如题的错误。

然后我把两个库直接全部都卸了,结果还是有这个错误!这我就感觉有问题了,库都没了,怎么错误还是这样?可能这个pip都没影响到conda的site package。

我自己的做法

只能手动删了……

找到OpenSSL的库在哪,可以看到在site package那里。

/home/anaconda3/lib/python3.9/site-packages/OpenSSL/crypto.py", line 3279, in 

直接rm -r OpenSSL

再次conda install xxxx尝试,可以了!

手动删除了这个库,那么conda再次install的时候会根据当前环境自行下载/更新所缺失的东西,这样就不劳烦我们自己了。

小结

先尝试2个库降级。如果不行的话,卸载2者,如果还出现相同的错误,则说明当前的pip命令没影响到conda的库(具体什么原因你可以找,我就懒得找了),那就要么解决pip,让其影响,再不就手动删除site package中的OpenSSL的库,之后让conda自行解决。

你可能感兴趣的:(【非抄袭】AttributeError module ‘lib‘ has no attribute OpenSSL_add)