问题
I have a Virtual env for my django project, but when I hit pip freeze
, I get what must be a global site package list, includes too many packages, like ubuntu packages and so much irrelevant stuff. This happens whether virtualenv is active or not. My site packages list looks a bit slim too, so I wonder whether venv has been working at all.
(env)~/code/django/ssc/dev/env/lib/python2.7/site-packages> ls
django
Django-1.4-py2.7.egg-info
easy-install.pth
pip-1.0.2-py2.7.egg
setuptools-0.6c11-py2.7.egg
setuptools.pth
What's my problem?
回答1:
If your virtual environment has access to the system's site-packages dir (ie. you used virtualenv --system-site-packages
) then it's normal for the list to be a rather long one.
Compare the following:
$ virtualenv --system-site-packages v1 && source v1/bin/activate
$ (v1) pip freeze | wc -l # 100
$ virtualenv v2 && source v2/bin/activate
$ (v2) pip freeze | wc -l # 2
Can you try recreating the virtualenv?
Alternatively, adding a no-global-site-packages.txt
file should tell pip to ignore the global site-packages:
$ touch $VIRTUAL_ENV/lib/python${version}/no-global-site-packages.txt
来源:https://stackoverflow.com/questions/12552631/pip-requirements-outputting-global-packages