python 3.6.10 pip3 TLS/SSL not configured



我是Python中的一名工程师,一些问题正在发生。这是一个用于安装python 3.6.10:的脚本

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install zlib1g-dev
apt-get install -y libxml2-dev libxslt1-dev libffi-dev libssl-dev
apt-get install -y libgdal-dev
apt-get install -y tor
apt-get install -y unzip
apt-get install -y s3cmd
apt-get install -y libfreetype6-dev
apt-get install -y pkg-config
apt-get install -y qt5-default
apt-get install -y libqt5webkit5-dev
apt-get install -y texinfo
apt-get install -qy firefox xvfb
apt-get install -y tree
apt-get install -y htop
apt-get install -y chromium-browser
sudo apt-get install build-essential checkinstall 
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd /opt
sudo wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz
sudo tar -xvf Python-3.6.10.tgz
cd Python-3.6.10
sudo ./configure --with-ssl

sudo make
sudo make install

sudo apt-get install -y build-essential python-pip python3-pip git
sudo -H pip install --upgrade pip
sudo -H pip3 install --upgrade pip

除了pip3之外,安装似乎工作正常。错误正在发生,我没有找到解决方案。

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/pip/
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages (18.1)
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

我该怎么修?为什么会发生这种事?

首先:您的Python构建应该允许您使用python3 -m pip作为pip命令。无论如何,-m标志都是一种很好的做法,因为它可以确保您将使用的pip与正确的Python解释器相关联。因此,不需要安装python-pip python3-pip。*

第二:关于SSL选项,您可能需要python-openssl。具有讽刺意味的是,当我试图在packages.ubuntu.com上搜索它时,我遇到了一个服务器端错误,但它在这个最新的示例中与libssl-dev一起显示。

这里有一个Dockerfile演示了以上两点:

docker image build -f Dockerfile.60814903 -t so60814903:1 .
docker container run -it --rm so60814903:1

在该shell中,您应该看到您有可用的python3 -m pip

最后一个技巧是,考虑一个可以帮助您同时管理多个Python版本的解决方案。pyenv就是这样一个工具,还有其他工具。


具体而言,默认情况下./configure将使用--with-ensurepip='upgrade'。下面是一个使用--with-ensurepip=no并单独安装pip的安装示例

最新更新