在 Python / Visual Studio Code 中安装模块的问题

Posted

技术标签:

【中文标题】在 Python / Visual Studio Code 中安装模块的问题【英文标题】:Problems with installing modules in Python / Visual Studio Code 【发布时间】:2022-01-23 00:38:09 【问题描述】:

我想在我的虚拟环境中导入一些模块,例如 Flask、Pandas、Matplotlib 等。 但问题是终端返回了以下问题:

(env) PS C:\Users\User\Desktop\Mehr\Python\Blockchain-Course> pip install matplotlib
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/matplotlib/
WARNING: Retrying (Retry(total=3, 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/matplotlib/
WARNING: Retrying (Retry(total=2, 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/matplotlib/
WARNING: Retrying (Retry(total=1, 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/matplotlib/
WARNING: Retrying (Retry(total=0, 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/matplotlib/
Could not fetch URL https://pypi.org/simple/matplotlib/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/matplotlib/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement matplotlib (from versions: none)
ERROR: No matching distribution found for matplotlib
WARNING: You are using pip version 21.2.3; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Users\User\Desktop\Mehr\Python\Blockchain-Course\env\Scripts\python.exe -m pip install --upgrade pip' command.

我从来没有遇到过任何问题,昨天它运行良好,有人知道该怎么做吗?

【问题讨论】:

这可能会有所帮助 - pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available 这能回答你的问题吗?:***.com/questions/45954528/… 【参考方案1】:

问题可能是由其他软件放置在C:\Windows\System32 文件夹(例如libcrypto-1_1-x64.dll 或libssl-1_1-x64.dll 或其他)中的DLLs 引起的。

可能会修复从https://slproweb.com/products/Win32OpenSSL.html 安装openSSL 的问题,它会用更新的版本替换 dll。

【讨论】:

除了下载这个程序还有其他方法吗?我觉得不安全【参考方案2】:
    先安装openssl,请参考this page 安装python和./configure --with-openssl=/home/username/openssl 终于 运行 python -m ssl 没有任何输出,没关系。

您可以参考this page了解更多详情。

【讨论】:

以上是关于在 Python / Visual Studio Code 中安装模块的问题的主要内容,如果未能解决你的问题,请参考以下文章

用visual studio 2017来调试python

Visual Studio 2013进行python开发

Visual Studio2017 Python添加包

Visual Studio上开发Python六大功能

Visual Studio中的奇怪Python包导入行为

Python与Visual Studio代码 - 运行特定文件