我已经在我的本地机器上成功安装了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>?
从源代码构建是我在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
I finally solve this issue. These are the detail of my env:
Version of Python to install: 3.6.8
OS: Ubuntu 16.04.6 LTS
Root access: No
Some people suggest to install libssl-dev, but it did not work for me. I follow this link and I fixed it!
In short, I download, extract, build, and install OpenSSL (openssl-1.1.1b.tar.gz). Then, I modify .bashrc file follow this link.
Next, I download and extract Python-3.6.8.tgz. I edit Modules/Setup.dist to modify SSL path (lines around #211). I did ./configure --prefix=$HOME/opt/python-3.6.8, make and make install. Last, I modify my .bashrc. Notice that I do not include --enable-optimizations in ./configure.