I thought that virtualenv was supposed to encapsulate and hide all of your packages that were already installed. But when I type
$sudo virtualenv -p /usr/bin/python3 testenv
$source ~/testenv/bin/activate
$sudo pip list
I get:
apt-xapian-index (0.45)
argparse (1.2.1)
chardet (2.0.1)
cmsplugin-filer (0.10)
colorama (0.2.5)
command-not-found (0.3)
debtagshw (0.1)
defer (1.0.6)
dirspec (13.10)
...and many more
Even with the --local
parameter. Is virtualenv broken?
Also when I type: $ which pip
I still get: /home/jelikraftuser/testenv/bin/pip
Which seems correct.
Reading the answers in this post: pip installing in global site-packages instead of virtualenv
I found the suggestion to run pip directly with $sudo ~/testenv/bin/pip list
and it actually worked, it only listed 2 packages. However when I run which pip
it lists the pip in the virtualenv as being the one which would be run.
So I'm sort of lost at this point. Calling the pip list with the full path gives me the correct (small) list of two packages, and calling pip list without the full path gives me a giant list of packages, which is incorrect. So, where do I go from here?
How can I make it not recognise globally installed packages as being installed in the virtualenv when I run pip without the full path?
OKAY UPDATE! This is kinda interesting:
(testenv)$ pip --version
pip 1.5.6 from /home/jelikraftuser/testenv/lib/python3.4/site-packages (python 3.4)
(testenv)$ sudo pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
When I run pip as sudo it runs one, and when i run it as non-sudo it runs a different pip. Why would it do that? And if I'm going to be installing a package, i'll be running it as sudo, so I need sudo to use the correct pip.
Second update:
Reading this stackoverflow:sudo changes PATH - why? I found that on ubuntu you cannot change the path variable for sudo, but this still confuses me since it was working before... So I'm still confused. Insight anyone? Previously I could type sudo pip list in a virtualenv and get a near-empty list. Does it do the same for you?
EDIT 3: What else it does:
When I run sudo pip install --download-cache=~/.pip-cache -r piprequirements.txt
it says that everything is already installed but when I enter python I cannot import them, but when I run python as sudo I can import them. So superuser can see packages that are globally installed > but I need to use sudo to install packages > so I can't install packages that are already globally installed. Also when I try to run pip3 as sudo, it says sudo: pip3: command not found
. So this is definately an issue with ubuntu and how the environment path changes when you run sudo. Is not everyone else running into this issue then? I'm sure lots of people are using ubuntu, no?