Linux离线模式下的pip安装要求

时间:2019-06-10 06:17:47

标签: python pip

我正在离线 Linux环境中工作。 (RedHat 7.6) 直到今天,我已经使用完整路径进行安装 带有pip的文件,效果很好。 (还是做)

现在进行自动化测试,我想创建一个虚拟的 环境和pip安装需求文件。

问题是,它不断搜索网络, 即使我使用过--prefix,并尝试过--target 我无法从某个文件夹安装它, 总是尝试在网上搜索

需求文件:

numpy==1.16.4

文件夹:

/custom_dev/install/

在文件夹内:

numpy-1.16.4-cp37-37m-manylinux_x86_64.whl

尝试:

pip3 install -r requirements.txt --target=/custom_dev/install/
pip3 install -r requirements.txt --prefix=/custom_dev/install/

和StackOverflow上的其他内容,我还没有找到解决问题的方法,或者是具有相同建议的线程?

ty!

2 个答案:

答案 0 :(得分:3)

我们的pip-local做到了:

c:\srv\bin> cat pip-local.bat
@echo off
rem pip install with `--upgrade --no-deps --no-index --find-links=file:///%SRV%/wheelhouse`

pip %* --upgrade --no-deps --no-index --find-links=file:///%SRV%/wheelhouse

Linux版本使用$*代替%*$SRV代替%SRV%

pip $* --upgrade --no-deps --no-index --find-links=file:///${SRV}/wheelhouse

如果您还希望找到依赖项,则可以删除--no-deps(尽管如果找不到在操舵室中满足依赖关系的轮子,它将搜索网络)。

随行工具为getwheel

c:\srv\bin> cat getwheel.bat
@echo off
rem
rem Download wheel file for  package (getwheel foo==1.4.1)
rem

pip wheel --wheel-dir=%SRV%\wheelhouse %*

Linux版本:

pip wheel --wheel-dir=${SRV}/wheelhouse $*

其用法类似于:

getwheel numpy==1.16.4

getwheel -r requirements.txt

这会将包裹的轮子及其依赖项放置在wheelhouse文件夹中。

答案 1 :(得分:0)

pip3 install -r requirements.txt --find-links=/custom_dev/install/ --no-index

阻止pip通过网络连接到PyPI的关键字是--no-index

相关问题