遇到一种奇怪的情况,其中pip install
可以正常工作,但是pip3 install
失败并显示以下消息。一切工作正常,直到最近我才第一次使用虚拟环境。
$ pip3 install yahoo_fin
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: yahoo_fin in /usr/local/lib/python3.7/site-packages (0.8.2)
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
我碰到过几篇类似的文章,我想我都尝试过所有这些文章,包括brew install openssl
,brew reinstall python
,pip3 install certifi
...但它们都不起作用。
供参考:
$其中python3:
/usr/local/bin/python3
$其中pip3
/usr/local/bin/pip3
$ python3 --version
Python 3.7.4
当我碰壁时,任何帮助将不胜感激。
自原始帖子以来的其他信息
当我运行以下命令时:
$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
它返回:
LibreSSL 2.2.7
但是,当我运行它时:
python3 -c "import ssl; print (ssl.OPENSSL_VERSION)"
我知道了:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: dlopen(/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib
Referenced from: /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so
Reason: image not found
错误是否超出了问题的关键?如果是这样,我该如何解决?
答案 0 :(得分:0)
当我尝试使用conda安装软件包时,我也发生了类似的问题。解决方案是将以下路径添加到我的系统变量中:
我认为pip /您的python解释器可能与这些等效。
侧面说明:这也适用于非管理员用户,因为在某些情况下,人们会切换到conda,因为它允许安装没有管理员权限的Python。