52
votes

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"
2
distribute is what provides pip itself, so if you want to be able to use pip to install things in your virtualenv you need to start out with pip. pip depends on wsgiref. ā€“ Spike Gronim
pip does not depend on wsgiref ā€“ Hugo Tavares

2 Answers

44
votes

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

29
votes

To answer a slightly different question: you can exclude wsgiref (and any other similarly-problematic .egg files if you are unfortunate enough to have any for some reason) by doing pip freeze -l instead of pip freeze.

pip help freeze describes this option:

-l, --local If in a virtualenv, do not report globally-installed packages