PIP does not work in virtualenv

Asked

Viewed 1,323 times

0

After activating the virtutalenv Pip does not work, I get the following error

wilker@debian:~/Documentos/Git/Curso Django/Blog$ source bin/activate
(Blog) wilker@debian:~/Documentos/Git/Curso Django/Blog$ pip freeze
bash: /home/wilker/Documentos/Git/Curso Django/Blog/bin/pip: "/home/wilker/Documentos/Git/Curso: bad interpreter: Arquivo ou diretório não encontrado

But outside it works normally. I’ve removed Pip,and virtualenv and reinstalled them.

I tried again and got the same mistake.

wilker@debian:~/Documentos/Git/Curso Django$ virtualenv Blog
New python executable in /home/wilker/Documentos/Git/Curso Django/Blog/bin/python
Installing setuptools, pip, wheel...done.
wilker@debian:~/Documentos/Git/Curso Django$ cd Blog/
wilker@debian:~/Documentos/Git/Curso Django/Blog$ source bin/activate
(Blog) wilker@debian:~/Documentos/Git/Curso Django/Blog$ pip
bash: /home/wilker/Documentos/Git/Curso Django/Blog/bin/pip: "/home/wilker/Documentos/Git/Curso: bad interpreter: Arquivo ou diretório não encontrado

2 answers

0


The problem was the space in the directory name in "Django Course".

wilker@debian:~/Documentos/Git/Curso Django$ virtualenv Blog

Apparently the absolute path of a virtual environment should not contain spaces, as the scripts generated for virtualenv do not handle spaces well. As said in:

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 thesystem 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.

Taken from: https://stackoverflow.com/questions/7911003/cant-install-via-pip-with-virtualenv

0

Try using the command python -m pip install nome_do_pacote

Browser other questions tagged

You are not signed in. Login or sign up in order to post.