通过pip冻结忽略某些软件包及其依赖项 [英] Ignore certain packages and their dependencies with pip freeze

查看:107
本文介绍了通过pip冻结忽略某些软件包及其依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题基本上说明了一切.如何告诉pip freeze忽略某些包,例如pylintpep8及其依赖关系?

Title basically says it all. How can I tell pip freeze to ignore certain packages, like pylint and pep8, and their dependencies?

推荐答案

可用的选项很少

根本不关心pip输出中是否存在这些软件包.

Simply do not care about these packages being present in pip output.

通过某些grep过滤器过滤输出,并获得干净的结果.

Filter the output through some grep filter and have the result clean.

请注意,virtualenv中的pip冻结不会报告全局安装的软件包(但是对我来说,它通常报告argparsewsgiref-似乎没有什么是完美的.)

Note, that pip freeze in virtualenv does not report globally installed packages (however it typically reports argparse and wsgiref for me - nothing seems to be really perfect.)

这将调用pip冻结并根据需要修改输出(删除不需要的文件).

which would call pip freeze and modify the output as needed (removing unneeded files).

我知道,我可能没有为您提供所需的答案,但也许virtualenv接近您的需求,因为它允许这些软件包在全球存在,并且仍然不允许在pip冻结输出中包含这些软件包

I am aware, I probably did not give you the answer you asked for, but maybe the virtualenv is close to what you need, as it allows global presence of those packages and still allow not having these packages in output of pip freeze.

以防万一,您只关心将pylintpep8用作命令行工具,但不要求它们对pip freeze可见,有多种选择

In case, you just care about having pylint and pep8 available as command line tools, but do not require them visible to pip freeze, there are multiple options

如果将pylintpep8安装到单独的virtualenv中,请按which pep8which pylint查找可执行文件的位置,并将这些文件复制到可见的位置,例如到/usr/bin.您从virtualenv复制或移动的脚本在virtualenv中具有硬编码路径至所需的python包,即使复制后也可以安全运行(仅脚本,请勿触摸其他相关的virtualenv).请注意,无需激活给定的virutalenv即可使其正常工作.

If you install pylint and pep8 into separate virtualenv, find location of the executables by which pep8 and which pylint and copy these files somewhere, where they will be visible, e.g. to /usr/bin. The scripts you copy or move from virtualenv have hardcoded path to required python packages in the virtualenv and will safely run even when copied (just the scripts, do not touch the rest of related virtualenv). Note, that there is no need to activete given virutalenv to make that working.

系统范围内安装的命令行工具通常安装在适当的位置,这使得它们在全局范围内可见.同时,在virtualenv中调用pip freeze时,无法看到系统范围内已安装的软件包.

System wide installed command line tools are typically installed into location, which makes them globally visible. At the same time, system wide installed packages are not seen by pip freeze when called in virtualenv.

这篇关于通过pip冻结忽略某些软件包及其依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆