本文介绍了点要求输出全局包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的django项目有一个虚拟环境,但是当我按pip freeze时,我会得到一个全球站点软件包列表,其中包括太多的软件包,例如ubuntu软件包和许多无关的东西.无论virtualenv是否处于活动状态,都会发生这种情况.我的网站软件包列表看起来也有些苗条,所以我想知道venv是否一直在起作用.

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

我怎么了?

推荐答案

如果您的虚拟环境可以访问系统的站点软件包目录(即您使用的是virtualenv --system-site-packages),则列表较长会很正常一个.

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.

比较以下内容:

$ 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

您可以尝试重新创建virtualenv吗?

Can you try recreating the virtualenv?

或者,添加no-global-site-packages.txt文件应该告诉pip忽略全局站点包:

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

这篇关于点要求输出全局包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 05:28