pythonpipopen-sourcevirtualenvportal

Pip not working inside Virtual Env but works outside perfectly


Hello Guys I am tying to follow the installation here https://github.com/systers/portal and trying to deploy the server inside a virtual environment on my machine. After lots of errors I decided to install a fresh copy of Ubuntu 16.04 and start After the installation here are the things that I have installed using the given commands

I checked my current python and python3 versions using python --version and python3--version respectively and they are Python 2.7.12 and Python 3.5.2 respectively.

Easy Install. $ sudo apt-get install python-setuptools python-dev build-essential  
pip. $ sudo easy_install pip
virtualenv. $ sudo pip install --upgrade virtualenv.
python3-dev tools.$sudo apt-get install python3-dev

Now after that I created a virtual env and activated it using the following commands

$ virtualenv venv1 --python=/usr/bin/python3
$ source venv/bin/activate

But now when I run the third command

$ pip install -r requirements/dev.txt

or even do

$pip --version

I get the error

bash: /media/rohan/New Volume/portal/venv1/bin/pip: "/media/rohan/New: bad interpreter: No such file or directory

Also in /venv1/bin the files pip,pip3 ,pip3.5 are present

I tried sudo easy_install pip thinking that it will install pip in the virtual environment but it installs to /usr/local/bin

Also I tried by creating a virtual env using the code

$virtualenv venv --python=/usr/bin/python

But that also doesnt work and this time also same error comes and in /venv/bin pip pip2 pip2.7 are present

PLEASE HELP


Solution

  • The problem appears to be that the path to your virtualenv has a space in it that isn't being escaped somewhere it should be.

    Note the error you receive:

    /media/rohan/New: bad interpreter: No such file or directory
    

    So with that space in the path, it is trying to run a program that doesn't exist (/media/rohan/New) on a file that doesn't exist (Volume/portal/venv1/bin/pip).

    Renaming New Volume to something without spaces like new_volume and then recreating a virtualenv should resolve this.