10

I'm working on a remote server. When I try to install anything with pip within my virtual environment I get an error:

(venv) [barta@bivoj program]$ pip install -r requirements.txt 
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting joblib==0.11 (from -r requirements.txt (line 1))
  Could not fetch URL https://pypi.python.org/simple/joblib/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping

Everything is working fine with python 2.7. Can I solve this problem by myself (I don't have root access) or do I need to contact the administrator?

First I had this problem when I installed python 3.6 in my home folder. I figured that the problem might be because it's in my home folder, so I asked for a clean install of python 3.6.

I considered changing the setup.py and install again in my home, as suggested here by Claudio:

pip3 installs inside virtual environment with python3.6 failing due to ssl module not available

but I didn't find any openssl folder. There is openssl in /usr/bin, but that is not a directory. I searched for the ssl.h file, but did not find it anywhere.

Community
  • 1
  • 1
Tom83B
  • 2,059
  • 4
  • 18
  • 28
  • You can try to build a local python 3 with a local openssl. Or just ask the admin to install a packaged python 3 for you. – pvg May 11 '17 at 18:51

5 Answers5

10

Sounds like you've built python from source without libssl-dev present.

Run:

sudo apt-get install libssl-dev
sudo ./configure
sudo make altinstall
tread
  • 10,133
  • 17
  • 95
  • 170
Igonato
  • 10,175
  • 3
  • 35
  • 64
  • 1
    That's going to be difficult without root access. – pvg May 11 '17 at 18:50
  • Oh, sorry, skipped that part in the question, I'll update the answer – Igonato May 11 '17 at 18:51
  • @pvg Updated. (Take a look at this answer http://stackoverflow.com/a/5939170/723891) – Igonato May 11 '17 at 18:56
  • 1
    I'm not the person asking, although the question is about python 3, they appear to have a working python 2 with SSL as it is. Sanest thing is really to just get a hold of someone with privileges and have them install python 3 with the package manager. – pvg May 11 '17 at 19:02
3

Tested in Ubuntu 16.04/18.04

In Python-3.6.4/Modules/Setup uncomment the following lines:

#   SSL=/usr/local/ssl
#   _ssl _ssl.c \
#       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#       -L$(SSL)/lib -lssl -lcrypto

Then recompile the package:

$ sudo ./configure --enable-optimizations
$ sudo make altinstall

Also make sure that libssl-dev is installed (this is the package for debian, anyway).

This also works for Python-3.7.x.

Eagle
  • 327
  • 3
  • 13
inzem77
  • 129
  • 3
  • Unfortunately this did not work for me. sudo make altinstall gives the following error. /usr/src/Python-3.7.0/./Modules/_ssl.c:3674: undefined reference to `SSL_CTX_get_default_passwd_cb' /usr/src/Python-3.7.0/./Modules/_ssl.c:3675: undefined reference to `SSL_CTX_get_default_passwd_cb_userdata' collect2: ld returned 1 exit status make: *** [python] Error 1 – Goutham Anush Nov 04 '18 at 08:57
2

This is how I did:

sudo apt-get install libssl-dev
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -xvf Python-3.6.5.tgz
cd Python-3.6.5/

./configure
sudo make
sudo make install
YSC
  • 38,212
  • 9
  • 96
  • 149
PhilKo
  • 71
  • 3
0

I got same error but actually I created python environment using a latest version of python2.7.13 and this python version was installed via source:

./configure --prefix /usr/bin/python2.7.13
make altinstall

Then creating virtualenv:

virtualenv --python=/usr/bin/python2.7.13/bin/python2.7 py2.7.13env

After spending a lot of time I found that one library named libreadline6-dev was missing. So installed it:

sudo apt-get install libreadline6-dev

and repeated compile and make install steps as mentioned above and again created the virtual env. Everything worked fine this time!

Saurav Kumar
  • 563
  • 1
  • 6
  • 13
0

If this is Windows, you need to install OpenSSL https://slproweb.com/products/Win32OpenSSL.html

Mich
  • 3,188
  • 4
  • 37
  • 85