【问题标题】:python 3.6.10 pip3 TLS/SSL not configuredpython 3.6.10 pip3 TLS/SSL 未配置
【发布时间】:2020-03-24 07:30:47
【问题描述】:

我是 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

我该如何解决?为什么会这样?

【问题讨论】:

  • 查看stackoverflow.com/a/42328420/7954504,特别是libssl-dev,然后重新制作
  • 嗨,布拉德!不幸的是,它没有奏效。我已经安装了 libssl-dev。尝试安装您在帖子中建议的所有软件包,但仍然无法正常工作
  • 你为什么apt install pip,你从源代码编译的python安装不是已经自带pip了吗?
  • 它已经在我使用的脚本中了。但即使没有它,也没有什么不同。每当我尝试使用 pip3 时,都会出现 pip3 的这个问题。比如安装pandas或者其他包

标签: python-3.x ssl pip


【解决方案1】:

首先:您的 Python 版本应该允许您使用 python3 -m pip 作为您的 pip 命令。 -m 标志是 good practice anyway,因为它将确保您将使用的 pip 与正确的 Python 解释器相关联。所以,python-pip python3-pip 安装应该是不必要的。*

其次:关于 SSL 选项,您可能需要python-openssl。具有讽刺意味的是,当我尝试在 packages.ubuntu.com 上搜索此内容时,我遇到了服务器端错误,但它显示在 this up to date examplelibssl-dev 旁边。

Here 是一个展示以上两点的 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'Here 是使用 --with-ensurepip=no 并单独安装 pip 的安装示例。

【讨论】:

    猜你喜欢
    • 2016-12-01
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 2021-07-27
    • 2021-07-28
    • 1970-01-01
    相关资源
    最近更新 更多