关于python:非抄袭AttributeError-module-‘lib‘-has-no-attribute-OpenSSLadd

0次阅读

共计 2139 个字符,预计需要花费 6 分钟才能阅读完成。

网络做法

翻了下帖子,全副是降级,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 <module>

间接 rm -r OpenSSL

再次 conda install xxxx 尝试,能够了!

手动删除了这个库,那么 conda 再次 install 的时候会依据以后环境自行下载 / 更新所缺失的货色,这样就不劳烦咱们本人了。

小结

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

正文完
 0