[英]Why does pip freeze list “pkg-resources==0.0.0”?
On Ubuntu 16.04 with virtualenv 15.0.1 and Python 3.5.2 (both installed with apt
) when I create and activate new Python virtual environment with在 Ubuntu 16.04 上使用 virtualenv 15.0.1 和 Python 3.5.2(都安装了
apt
),当我创建并激活新的 Python 虚拟环境时
virtualenv .virtualenvs/wtf -p $(which python3) --no-site-packages
source .virtualenvs/wtf/bin/activate
I get the following output:我得到以下输出:
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/das-g/.virtualenvs/wtf/bin/python3
Also creating executable in /home/das-g/.virtualenvs/wtf/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
Indeed pip freeze --all
lists these 4 packages:确实
pip freeze --all
列出了这 4 个包:
pip==8.1.2
pkg-resources==0.0.0
setuptools==25.2.0
wheel==0.29.0
Though, I'd expect pip freeze
(without --all
) to omit these implicitly installed packages.不过,我希望
pip freeze
(没有--all
)省略这些隐式安装的包。 It does omit some of them, but not pkg-resources
:它确实省略了其中一些,但没有省略
pkg-resources
:
pkg-resources==0.0.0
(Same btw. for pip freeze --local
) (顺便说一句,同样适用于
pip freeze --local
)
While this is consistent with the help text虽然这与帮助文本一致
$> pip freeze --help | grep '\--all'
--all Do not skip these packages in the output: pip, setuptools, distribute, wheel
having pkg-resources
in the pip freeze
output doesn't seem very useful and might even be harmful.在
pip freeze
输出中包含pkg-resources
似乎不是很有用,甚至可能有害。 (I suspect it's why running pip-sync
from pip-tools uninstalls pkg-resources from the virtual environment, subtly breaking the environment thereby.) Is there any good reason why pip freeze
lists pkg-resources
instead of omitting it, too? (我怀疑这就是为什么从pip-tools运行
pip-sync
从虚拟环境中卸载 pkg-resources,从而巧妙地破坏环境。) pip freeze
是否也有充分的理由列出pkg-resources
而不是省略它? As far as I remember, it didn't list it on Ubuntu 14.04 (with Python 3.4).据我所知,它没有在 Ubuntu 14.04(使用 Python 3.4)上列出。
According to https://github.com/pypa/pip/issues/4022 , this is a bug resulting from Ubuntu providing incorrect metadata to pip.根据https://github.com/pypa/pip/issues/4022 ,这是由 Ubuntu 向 pip 提供不正确元数据导致的错误。 So, no there does not seem to be a good reason for this behaviour.
因此,这种行为似乎没有充分的理由。 I filed a follow-up bug with Ubuntu.
我向 Ubuntu 提交了一个后续错误。 https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
I had the same problem in my virtual environment.我在我的虚拟环境中遇到了同样的问题。 I removed it with
pip uninstall pkg-resources==0.0.0
我用
pip uninstall pkg-resources==0.0.0
删除了它
As mentioned in other answer this is a bug.正如其他答案中提到的,这是一个错误。 However, on linux you can use the following command to automatically remove the line containing
pkg-resources==0.0.0
.但是,在 linux 上,您可以使用以下命令自动删除包含
pkg-resources==0.0.0
。
$ pip freeze > requirements.in && grep -v "pkg-resources==0.0.0" requirements.in > temp && mv temp requirements.in
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.