0

I have created a virtualenv and activated it. However, when I run pip -V I get this output:

pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

One of the symptoms of this is that packages I install with pip are being put in /usr/local/lib/python2.7/site-packages instead of inside the virtualenv.

I checked the "shebang" line within the bin/pip script inside the virtualenv, and it points to the python interpreter within the virtualenv like it should.

which pip gives this output:

/home/alastair/Geekery/Courses/IT Masters/Configuration Management/venv-course/bin/pip
Alastair Irvine
  • 1,116
  • 12
  • 16

1 Answers1

0

When I tried to run venv-course/bin/pip -V I got this output:

venv-course/bin/pip: Command not found.

Yet the file is there and executable. In my experience, this only happens when Linux, MacOS, etc. cannot interpret the shebang line at the start of the script, and so declares it unrunnable.

Turns out the problem was spaces in my directory names, which meant that the shebang line was this:

#!"/home/alastair/Geekery/Courses/IT Masters/Configuration Management/venv-course/bin/python2"

On Linux at least, quotes and spaces are not usable when specifying the name of a script interpreter.

I tried editing the shebang line as follows, but it still didn't work (and no, the leading space is not a problem):

#! /home/alastair/Geekery/Courses/IT\ Masters/Configuration\ Management/venv-course/bin/python2

Solution

When I renamed the directories in the path to have underscores and then re-created the virtualenv, the shebang line was this:

#!/home/alastair/Geekery/Courses/IT_Masters/Configuration_Management/venv-course/bin/python2

This time, when I ran pip -V I get this output:

pip 1.5.6 from /home/alastair/Geekery/Courses/IT_Masters/Configuration_Management/venv-course/local/lib/python2.7/site-packages (python 2.7)
Alastair Irvine
  • 1,116
  • 12
  • 16