我已经在我的本地机器上成功安装了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>?


当前回答

如果在窗户和使用蟒蛇,比我先解决它,

conda activate
pip install <lib>

这对我很管用。

其他回答

前两天我也遇到了同样的问题,直到现在才解决。

我尝试使用digicert_high_asance_ev_root_ca的——trust-host选项。pem不工作,我无法安装ssl模块(它告诉它不能安装python版本大于2.6),设置$PIP_CERT变量也没有修复它,我安装了libssl1.0.2和libssl1.0.0。值得一提的是,我没有~/.pip/pip.conf文件,创建它也没有解决这个错误。

最终解决这个问题的方法是再次使用make安装python3.6。 下载Python-3.6.0。从网站TGZ,运行配置,然后使,使测试,使安装。希望这对你有用。

在Ubuntu中,这可以帮助:

cd Python-3.6.2
./configure --with-ssl
make
sudo make install

我在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。

这个问题可能是库丢失造成的。

在安装python 3.6之前,请确保安装了python所需的所有库。

$ sudo apt-get install build-essential checkinstall 
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

更多信息请参见如何在Ubuntu和LinuxMint上安装Python 3.6.0

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

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

or

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

\蟒蛇

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

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

\ bin \蟒蛇图书馆

\Anaconda\Scripts

\蟒蛇\图书馆

(anaconda \ condabin

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