Pip requirements outputting global packages

2019-05-10 20:31发布

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条回答
小情绪 Triste *
2楼-- · 2019-05-10 21:00

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
查看更多
登录 后发表回答