并排除特定的依赖项

并排除特定的依赖项

本文介绍了将安装安装到自定义目标目录,并排除特定的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用pip或类似方法将python软件包列表安装到自定义目标目录(例如/mypath/python/pkgs/)的方法,但还要排除/黑名单特定依赖性.

I'm looking for a method to use pip or similiar to install a list of python packages to a custom target directory (ex./mypath/python/pkgs/ ), but also exclude/blacklist specific dependencies.

我想排除特定的依赖关系,因为它们已经通过不同的安装路径得到了满足(例如anaconda安装).我没有特权将软件包添加到默认的python安装中(我也不想要).

I want to exclude specific dependencies since they are already met from a different install path (e.g. an anaconda install). I don't have the privilege of adding packages to the default python installation (nor do I want to).

我目前正在使用pip的-r和-t选项.但尚未找到排除特定程序包的方法.

I'm currently use the -r and -t options of pip. But have not found a way to exclude specific packages.

像这样的pip命令将是理想的:

A pip command like this is would be ideal:

pip install --log pip.log -r req.txt -t /mypath/pypkgs/ --exclude exclude.txt

--no-deps不是一个选项,因为我需要一些依赖项.

--no-deps is not an option since I need some of the dependencies.

我目前正在使用python脚本进行pip安装,这些安装包括不需要的依赖项,通过以下方式进行操作:

I'm currently pursuing a python script to do pip installs that include dependencies I don't need via:

pip install --log pip.log -r req.txt -t /mypath/python/pkgs/

,然后在pip安装完成后(自动)删除不需要的依赖项.

and then (automatically) remove the unneeded dependencies after the pip install finishes.

我希望pip命令的某种组合可以实现我正在寻找的一些简单方法.我正在使用7.1.2点.谢谢!

I hoping some combination of pip commands can achieve what I'm looking for some straightforward away. I'm using pip 7.1.2. Thanks!

类似,但我没有升级,但想指定目标路径:

Similar, yet I'm not upgrading and want to specify a target path:

pip:升级程序包而不升级特定的依赖项

推荐答案

遇到类似的问题,并且使用运行中的bash shell,我设法用

Faced with a similar problem, and using a running bash shell I managed to exclude specific packages with

pip install $(grep -ivE "pkg1|pkg2|pkg3" requirements.txt)

其中pkg1等是要排除的软件包的名称.

where pkg1 and so on are the names of the packages to exclude.

这篇关于将安装安装到自定义目标目录,并排除特定的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 20:35