1

I'm a begginer in Python, and some problems are happening. This is a script for installing 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


The installation seems to work properly, except by the pip3. Errors are occuring, and I didn't find the solution for that.

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

How can I fix it? And why it's happening?

Rafael Higa
  • 655
  • 1
  • 8
  • 17
  • See https://stackoverflow.com/a/42328420/7954504, specifically `libssl-dev`, and re-make – Brad Solomon Mar 23 '20 at 14:06
  • Hi, Brad! Unfortunately, it not worked. I have already installed libssl-dev. Tried to install all the packages you suggested in the post, but it still not worked – Rafael Higa Mar 23 '20 at 14:18
  • why do you `apt install` pip, does the installation of python you are compiling from source not come with pip already? – FlyingTeller Mar 23 '20 at 14:32
  • it was already in the script I used. But even without it, nothing different happened. This problem with pip3 happens anytime I try to use pip3. For example, install pandas or other package – Rafael Higa Mar 23 '20 at 14:37

1 Answers1

1

Firstly: your build of Python should allow you to use python3 -m pip as your pip command. The -m flag is good practice anyway as it will make sure that you're associating the pip you use with the correct Python interpreter. So, the python-pip python3-pip install should not be necessary.*

Secondly: with regards to the SSL option, it's possible you might need python-openssl. I am, ironically, getting a server-side error when I try to search for this on packages.ubuntu.com, but it's shown in this up to date example alongside libssl-dev.

Here is a Dockerfile demonstrating both of the above points:

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

In that shell, you should see that you have python3 -m pip available.

Last tip, consider a solution that will help you manage multiple Python versions alongside each other. pyenv is one such tool, and there are others out there also.


Specifically, ./configure by default will use --with-ensurepip='upgrade'. Here is an example of an installation that uses --with-ensurepip=no and installs pip separately.

Brad Solomon
  • 38,521
  • 31
  • 149
  • 235