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


当前回答

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

在安装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

其他回答

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

我尝试使用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 22.10上的工作方式:

手动安装OpenSSL,在这里用OpenSSL 1.1.1测试,提取然后运行:

./config --prefix='/opt/openssl' --openssldir='/opt/ssl'
make
make install

然后使用旧版本的Python 3(这里是Python-3.8.16)运行:

export LD_RUN_PATH='/opt/openssl/lib'
export CC='gcc-12'  # sudo apt install gcc-12
./configure --enable-optimizations \
            --with-openssl='/opt/openssl' \
            --prefix='/opt/python/3.8' -C
make
make install

测试:

/opt/python/3.8/bin/python3 -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 1.1.1s  1 Nov 2022

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

在安装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

降级openssl对我有用,

brew switch openssl 1.0.2s

特穆克斯

这是因为我没有安装现有的openssl版本。

pkg install openssl-tool