Pip not working inside Virtual Env but works outside perfectly
Asked Answered
P

2

10

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

Pheasant answered 13/12, 2016 at 15:45 Comment(2)
Please complete te post, also include the errorsCatholic
sorry it got posted by accident i didnt realize it Now its completed please checkPheasant
G
16

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.

Gadmon answered 13/12, 2016 at 16:4 Comment(2)
Nice catch. I really think this should be fixed in virtualenv. Unix devs/admins have been handling the issue of spaces in filenames/paths for decades yet there is a dispute about how to handle it in virtualenv.Gametophyte
Okay, this should be fixed in the future. That was really annoying me lolStagestruck
B
0

I had renamed the folder of virtual environment so that I was getting this error. Then I renamed the venv folder name to the path mentioned in the error (That is the one which I had named while creating venv.) then tried to use pip and it worked.

Might be you have already solved your issue, but this is for the future visitors.

Barranquilla answered 30/4, 2021 at 18:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.