Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does pip freeze report some packages in a fresh virtualenv created with --no-site-packages?

When I create a fresh virtualenv, pip freeze shows that I have a couple of packages installed even though I've not installed anything into the environment. I was expecting pip freeze to return empty output until after my first pip install into the environment. wsgiref is part of the standard library isn't it, so why does it show up at all?

 day@garage:~$ mkdir testing day@garage:~$ cd testing day@garage:~/testing$ virtualenv --no-site-packages . New python executable in ./bin/python Installing distribute.......................................................... ............................................................................... .........................................done. day@garage:~/testing$ . bin/activate (testing)day@garage:~/testing$ pip freeze distribute==0.6.10 wsgiref==0.1.2 

Some extra info:

 (testing)day@garage:~/testing$ pip --version pip 0.7.2 from /home/day/testing/lib/python2.7/site-packages/pip-0.7.2-py2.7.eg g (python 2.7) (testing)day@garage:~/testing$ deactivate day@garage:~/testing$ virtualenv --version 1.4.9 day@garage:~/testing$ which virtualenv /usr/bin/virtualenv day@garage:~/testing$ dpkg -S /usr/bin/virtualenv python-virtualenv: /usr/bin/virtualenv day@garage:~/testing$ cat /etc/lsb-release  DISTRIB_ID=Ubuntu DISTRIB_RELEASE=11.04 DISTRIB_CODENAME=natty DISTRIB_DESCRIPTION="Ubuntu 11.04" 
like image 282
Day Avatar asked Jul 08 '11 15:07

Day


People also ask

How do I see what packages are installed in Virtualenv?

Show activity on this post. You can list only packages in the virtualenv by pip freeze --local or pip list --local . This option works irrespective of whether you have global site packages visible in the virtualenv .

What does Python pip freeze do?

pip freeze is a very useful command, because it tells you which modules you've installed with pip install and the versions of these modules that you are currently have installed on your computer. In Python, there's a lot of things that may be incompatible, such as certain modules being incompatible with other modules.

Can not perform a '-- user install user site packages are not visible in this Virtualenv airflow?

If this command returns Can not perform a '--user' install. User site-packages are not visible in this virtualenv. then you are already in a Python virtual environment. You will need to deactivate this environment or contact your system administrator to install virtualenv for you in this environment.


1 Answers

Everytime you create a virtualenv with --no-site-packages it installs setuptools or distribute. And the reason wsgiref appears is because python 2.5+ standard library provides egg info to wsgiref lib (and pip does not know if it stdlib or 3rd party package).

It seems to be solved on Python3.3+: http://bugs.python.org/issue12218

like image 166
Hugo Tavares Avatar answered Oct 17 '22 02:10

Hugo Tavares