我已经在我的本地机器上成功安装了Python 3.4和Python 3.6,但无法安装带有pip3的包。

当我执行pip3 install <package>时,我得到以下SSL相关错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting <package>
  Could not fetch URL https://pypi.python.org/simple/<package>/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement <package> (from versions: )
No matching distribution found for <package>

如何修复我的Python3。pip install <package>?


当前回答

我尝试了很多方法来解决这个问题,但没有一个解决。我现在用的是Windows 10。

唯一有效的方法是:

卸载蟒蛇 卸载Python(我使用的是3.7.3版本) 再次安装Python(记得勾选自动添加到PATH的选项)

然后我用PIP下载了我需要的所有lib…和工作!

不知道为什么,或者这个问题是否与水蟒有关。

其他回答

我可以通过更新这个文件中的python版本来修复这个问题。 pyenv: version ' 3.6.5'未安装(由/Users/taruntarun/.python-version设置) 虽然我安装了最新版本,但我的命令仍然使用旧版本3.6.5

转到3.7.3版本

我在Debian9上安装python3.8.5时也遇到了同样的问题。我已经做了一个构建,但是当我尝试下载一些模块时,pip3.8出现了以下错误:

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

我已经搜索了问题的根源,发现python构建中有一个依赖于系统的部分是由系统独立的部分调用的。如果没有ssl,你只需要打开python终端,检查_ssl是否存在:

>>> help('modules')
.
.
_sre                enum                pwd                 wave
_ssl                errno               py_compile          weakref
_stat               faulthandler        pyclbr              webbrowser
.
.

如果不是,您的系统依赖ssl模块部分是缺失的。你也可以通过列出<python_installation_root>/lib/python3.8/lib-dynload的内容来检查:

>ls ./lib/python3.8/lib-dynload | grep ssl
_ssl.cpython-38-x86_64-linux-gnu.so

这个问题是由PengShaw编写的,因为在构建过程中缺少libssl-dev。因此,您必须遵循推荐的python安装流程。首先安装先决条件,然后构建和安装python。在没有devel版本的库的情况下安装导致我的案例中缺少系统依赖部分。在本例中是_ssl。

注意Debian和CentOS的devel库名称不同,因此请检查网上发布的安装提示是否适合您特定的Linux系统类型:

For Debian:
sudo apt install -y libbz2-dev libffi-dev libssl-dev
./configure --enable-optimizations
make
make altinstall


For CentOS:
sudo yum -y install bzip2-devel libffi-devel openssl-devel
./configure --enable-optimizations
make
make altinstall

在配置和evtl之前列出配置选项肯定是个好主意。使用一些额外的选项:

./configure --help

最后但并非最不重要的是,如果您使用——prefix作为非默认安装位置,请记住将<python_installation_root>/lib添加到LD_LIBRARY_PATH。

你可以做这两件事中的任何一件:

在安装Anaconda时,选择将Anaconda添加到路径的选项。

or

从Anaconda的安装文件夹中找到这些(完整的)路径,并将它们添加到环境变量中:

\蟒蛇

\ \图书馆\ mingw-w64 \ bin的水蟒

\ \图书馆\ usr \ bin的水蟒

\ bin \蟒蛇图书馆

\Anaconda\Scripts

\蟒蛇\图书馆

(anaconda \ condabin

将上述路径添加到“Path”系统变量中,它应该不再显示错误了:)

如果你使用的是Red Hat/CentOS:

# To allow for building python ssl libs
yum install openssl-devel
# Download the source of *any* python version
cd /usr/src
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz 
cd Python-3.6.2

# Configure the build w/ your installed libraries
./configure

# Install into /usr/local/bin/python3.6, don't overwrite global python bin
make altinstall

我在OSX 10.11上遇到了类似的问题,因为在3.6之上安装了python 3.7的memcached。

警告:pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。

花了几个小时解链接openssl,重新安装,改变路径。但一切都无济于事。将openssl版本从旧版本更改为旧版本,做到了这一点:

brew switch openssl 1.0.2e

我在网上没有看到这个建议。希望它能为某人服务。