0

In a virtual environment activated in a virtual machine, I can't install any package with pip, since it raises a SSL related error.

I'm setting up a virtual environment (with virtualenv) to mimic the the settings of a server that I'm going to work with. So I installed mannualy (from tar file) a specific version of python (3.7.0) in a Ubuntu 18.04 virtual machine (using VirtualBox). Once my python version of choice was running I activated a virtual environment. The pip version is 18.1.

The problem comes when I try to install a python package, like:

$ pip install django

It raised this error:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting django
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/django/
Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement django (from versions: )
No matching distribution found for django

Neither of the answers that I found after searching helped me. Since pip can't install anything, it can't install packages like ssl nor OpenSSL. If anyone can help me, I thank a lot in advance.

7
  • Can you use Ubuntu's package manager to install python3.7 instead of using a tar file? Then, for one, you'd probably get the ssl module (which is part of the standard library) by default. Otherwise, you probably need to get the ssl library into your tarball. How did you make the tarball? Jan 16, 2019 at 18:16
  • 2
    If you compiled python from source tarball, then you didn't link against OpenSSL and thus no SSL module. The solution in this case is to remove python and recompile it again, linking against the OpenSSL lib. If you downloaded the distribution somewhere else, then its author compiled it without OpenSSL and the distribution is unusable; find another one.
    – hoefling
    Jan 16, 2019 at 19:34
  • 1
    still, why not just install python3 from apt-get in the Ubuntu vm? Jan 16, 2019 at 20:44
  • @hoefling How can I link it against OpenSSL? I downloaded the distribution from python.org itself.
    – handraqui
    Jan 17, 2019 at 0:29
  • @JawguyChooser I didn't realize how could I install exactly Python 3.7.0 through other way than installing from .tar file. I can specify 'sudo apt-get install python3.7', installing 3.7.1, but 'sudo apt-get install python3.7.0' won't work.
    – handraqui
    Jan 17, 2019 at 0:29

1 Answer 1

0

I wasn't able to install pandas-datareader. I was getting the same error message. Then, in the CMD window, I just put the command "activate base" and then ran pip again and it worked. I tried with django before and after the "activate base" and if it didn't work before, it did work after. I think it's just some environment variables that are not configured properly. Luckily this will work for you as well. Have a nice day Rémy

1
  • Thanks for your help! But, unfortunately, it didn't work to me, since I'm using Linux Ubuntu. activate base wasn't recognized as a existent command.
    – handraqui
    Jan 18, 2019 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.