2

I'm new to virtualenv, and was trying to get it working, in order to work with a given project. I've followed this guide to set it all up. As soon as I get in the virtualenv, pip stops working with the mentioned error.

The exact issue here being this:

(virtual-env) $ pip install --trusted-host pypi.python.org Django==1.11.4
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting Django==1.11.4
  Could not fetch URL https://pypi.python.org/simple/django/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement Django==1.11.4 (from versions: )
No matching distribution found for Django==1.11.4

...yes... --trusted-host makes no difference... it seems, because it needs some package I cannot find.

Versions:

  • Python

    $ python --version
    Python 3.6.2
    
  • Pip

    $ pip --version # <- Edited
    pip 9.0.1
    

I did try to install the ssl module, but to no avail. Turns out you cannot install ssl with python 3. The problem is the print sintax.

  [...]
  File "/tmp/pip-build-undfmh27/ssl/setup.py", line 33
    print 'looking for', f
                      ^
SyntaxError: Missing parentheses in call to 'print'

Any help is appreciated

coya
  • 264
  • 2
  • 15
  • 1
    A few notes. You show us `pip3 --version` but run `pip install`; `pip` (not `pip3`) is supposed to be Python 2.7. The error about missing parentheses in `print` is again Py2 vs Py3: in python 3 `print` is a function `print()`. The module `ssl` at PyPI is [Py2 only](https://github.com/pypa/ssl/issues/7); for Py3 you don't need to install anything — everything is in Python already. – phd Aug 04 '17 at 06:38
  • You are almost right. The thing is, within the virtualenv, pip is nothing but a symbolic link to pip3. I've edited the question to clarify. Thank you! – coya Aug 05 '17 at 17:16
  • 1
    Answer to [this](https://stackoverflow.com/questions/47822740/how-to-use-virtualenv-with-python3-6-on-ubuntu-16-04) question help me with similar to your problem – Dmitriy Kisil Oct 17 '18 at 15:52

1 Answers1

2

Well... turns out that ther is a certain order for installing stuff with python 3.6. This post was very helpful.

Following this instructions I was able to make my virtualenv work as I expected.

To sum up. Before installing python 3.6.2 as in the question, you need to prepare the environment as follows:

$ sudo apt-get install build-essential checkinstall
$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

And only then, install python 3, and use it within the virtualenv.

coya
  • 264
  • 2
  • 15