我使用的是Python 3.6。当我尝试使用pip3安装“模块”时,我遇到了这个问题:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
我使用的是Python 3.6。当我尝试使用pip3安装“模块”时,我遇到了这个问题:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
当前回答
此问题是由于您的PC上缺少OpenSSL包。
如果pip install openpyxl也给出错误。
你可以通过以下站点安装OpenSSL(Win64 OpenSSL v1.1.1g)来解决这个问题:
slproweb.com/products/Win32OpenSSL.html
重新启动您正在使用的IDE,使更改生效。
其他回答
对于未来试图解决这个问题的Oracle Linux用户,下面是对我有用的方法。 首先安装缺少的库:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
然后cd到Python3。X库并运行:
make
make install
你可以尝试brew链接,它会告诉你正确的说明:
$ brew link openssl --force
Warning: Refusing to link macOS provided/shadowed software: openssl@1.1
If you need to have openssl@1.1 first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl@1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
For pkg-config to find openssl@1.1 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
我简单地用以下命令解决了这个问题:
Brew升级python@3.9
这个版本默认包含SSL !
在我的情况下,我在Linux上的$PATH遇到了问题。这也可能发生在MacOS上。
检查/usr/bin/pip3 install package_name_goes_here是否适合您。如果是,那么运行 这将告诉您pip3安装在哪个目录中。
如果它类似于/usr/local/bin/pip3,与/usr/bin/pip3不同,那么您可能需要调整您的$PATH。
运行 echo $PATH并复制结果。
PATH只是一个冒号分隔的包含目录的目录列表。Bash将始终返回您试图执行的程序的第一个实例。将所有系统目录移到前面。下面是一些系统目录的列表:
/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
如果失败,则验证您已经安装了openssl,运行openssl version -a如果没有,则安装openssl。
此问题是由于您的PC上缺少OpenSSL包。
如果pip install openpyxl也给出错误。
你可以通过以下站点安装OpenSSL(Win64 OpenSSL v1.1.1g)来解决这个问题:
slproweb.com/products/Win32OpenSSL.html
重新启动您正在使用的IDE,使更改生效。