Can't install via pip with Virtualenv
Create your virtualenv environment within a path without spaces. This is why it is happening:
When you create an environment, it sets up a bin
directory. In that bin
directory are all the executables relating to the environment. Some are scripts. As you may know, hashbangs are used to tell the system what interpreter to use to run the script. You may see this at the top of scripts often:
#!/usr/bin/env python
If the script is at /tmp/test.py
, that tells the system to run this command to execute the script:
/usr/bin/env python /tmp/test.py
In your case, virtualenv is creating scripts like this:
#!/tmp/oh no/bin/python
When the system tries to execute that, it will try to execute the command /tmp/oh
with the arguments no/bin/python
and /tmp/test.py
. /tmp/oh
does not exist, so it fails.
For those running into this issue, I discovered that the length of the path could cause issues as well, without using any spaces (Ubuntu 12.04):
virtualenv /home/user/some/very/longer/path/without/spaces/etc/venv
failed, while
virtualenv /home/user/some/very/long/path/without/spaces/etc/venv
worked just fine, see Alex's comment below
pip
command won't work if:
- You have not installed pip in your system. (you have to install pip first in your system before you can use it in virtualenv. To install
pip
on Ubuntu, use commandsudo apt-get install python-pip
orsudo apt-get install python3-pip
) - The path to your virtual environment folder contains space(s).(Example: /home/username/my folder name with spaces/newvirtualenv)
- The path to your virtual environment folder is too long. Example: /home/username/mytoobigpath/somefolder/anotherfolder/someanotherfolder/someanotherfolderagain/myvirtualenv. (Try renaming parent folders with smaller names)
If you can't rename folders or change path for some reason, goto yourvirtualenvfolder/bin
(using cd
command) and then try ./python pip install packagename
.