简体   繁体   English

使用 --target 安装的软件包的 Pip 冻结

[英]Pip freeze for packages installed with --target

I would like to use for a small Python project this way of managing dependent modules: http://blog.zoomeranalytics.com/pip-install-t/我想使用这种管理依赖模块的方式用于小型 Python 项目: http : //blog.zoomeranalytics.com/pip-install-t/

In brief, I would do:简而言之,我会这样做:

cd myproject

pip install --target ./pip-libs --upgrade -r requirements.txt

then add ./pip-libs to PYTHONPATH and run my script.然后将 ./pip-libs 添加到 PYTHONPATH 并运行我的脚本。

This seems but I like to use use pip freeze and it does not allow me to do anything like这似乎但我喜欢使用 pip freeze 并且它不允许我做任何类似的事情

pip freeze --target pip-libs

to see packages installed in the folder.查看安装在文件夹中的软件包。 Of course, I can take a look inside but what is a standard way to show packages installed in a folder with --target?当然,我可以看看里面,但是使用 --target 显示安装在文件夹中的包的标准方法是什么? The only way I can think of is doing ls of pip-libs and then playing with grep, awk... Does not seem right.我能想到的唯一方法是做ls of pip-libs 然后玩 grep, awk ... 似乎不对。

I am not sure if there is a way, maybe it's not a good idea or I should request such functionality for pip.我不确定是否有办法,也许这不是一个好主意,或者我应该为 pip 请求这样的功能。

Python 2.7.9.蟒蛇 2.7.9。

聚会有点晚了,但我遇到了同样的问题,这似乎解决了它。

pip freeze --path ./pip-libs > requirements.txt

Unfortunatly, you cant do it with pip freeze .不幸的是,你不能用pip freeze做到这pip freeze The docs say that pip install installs into that target folder, but its still within your path.文档说pip install安装到该目标文件夹中,但它仍在您的路径中。 So pip freeze only shows what packages are installed, not what are installed in a particular place.所以pip freeze只显示安装了哪些包,而不是在特定位置安装了哪些包。

You could look at pip show which does contain information on where they are installed (see https://pip.pypa.io/en/stable/reference/pip_show/ ) but you would have to write some sed/awk or similar to do a grep on the line "Location" and then go back and get the package name.你可以看一下pip show其确实包含上安装了他们的信息(见https://pip.pypa.io/en/stable/reference/pip_show/ ),但你会写一些SED / AWK或类似的做在“位置”行上使用 grep 然后返回并获取包名称。

The other option is to just look at the folders in the install folder and manually work out what the packages where from that... something like:另一种选择是只查看安装文件夹中的文件夹,然后手动找出包的来源......类似:

ls ./pip-libs | grep -v .dist-info

这应该工作

PYTHONPATH=./pip-libs pip freeze
pip freeze --path [path location]

对于当前文件夹:

pip freeze --path .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM