在 VSCode 虚拟环境中安装 numpy 时,pip 配置了需要 TLS/SSL 的位置

问题描述

我收到错误

pip is configured with locations that require TLS/SSL,however the ssl module in Python is not available.

尝试在 Visual Studio 代码中的虚拟环境中安装 numpy 时。我注意到以下几点:

  1. 如果我在 VS 代码中的虚拟环境之外执行“pip install numpy”,则一切正常。
  2. 虽然我使用“py -3 -m venv NameOfVirtualEnvironment”在 VS 代码中创建虚拟环境,但没有创建 .vscode 文件
  3. 我无法按照之前类似帖子中的建议执行“pip install SSL”或任何其他补救措施来解决问题。
  4. 我可以在命令窗口中顺利“pip install numpy”。

这是我收到的详细错误消息:

pip is configured with locations that require TLS/SSL,however the ssl module in Python is not available.
Collecting numpy
  retrying (Retry(total=4,connect=None,read=None,redirect=None,status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  retrying (Retry(total=3,status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  retrying (Retry(total=2,status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  retrying (Retry(total=1,status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  retrying (Retry(total=0,status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org',port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)