Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

python - 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"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...