简体   繁体   English

为什么pip冻结列表“pkg-resources==0.0.0”?

[英]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.

相关问题 pip freeze 命令输出中的“pkg-resources==0.0.0”是什么 - What is "pkg-resources==0.0.0" in output of pip freeze command 找不到满足要求的版本 pkg-resources==0.0.0 - Could not find a version that satisfies the requirement pkg-resources==0.0.0 Elastic Beanstalk,Django 部署错误,找不到满足要求的版本 pkg-resources==0.0.0 - Elastic Beanstalk, Django deployment error, Could not find a version that satisfies the requirement pkg-resources==0.0.0 为什么`pip freeze`会导致一个空文件? - Why does `pip freeze` result in an empty file? 为什么 Pip 似乎将自己排除在“pip freeze”之外? - Why does Pip seem to exclude itself from “pip freeze”? Python pip pkg_resources.DistributionNotFound - Python pip pkg_resources.DistributionNotFound python pip 错误 pkg_resources.DistributionNotFound - python pip error pkg_resources.DistributionNotFound pip install broken(pkg_resources.find_distribution返回req.py-prepare_files中的空列表) - pip install broken (pkg_resources.find_distribution returns empty list in req.py-prepare_files) Python Pip:没有名为 pkg_resources 的模块 - Python Pip: No module named pkg_resources Python pip说:pkg_resources.DistributionNotFound:pip == 1.4.1 - Python pip says: pkg_resources.DistributionNotFound: pip==1.4.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM