脱机模式下的Pip安装要求linux

2024-05-17 18:23:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我在一个离线的Linux环境中工作。(红帽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的其他内容,我还没有找到解决问题的方法,或者有相同的线程,建议?你知道吗

泰!你知道吗


Tags: installpip文件devnumpytxt文件夹target
2条回答
pip3 install -r requirements.txt  find-links=/custom_dev/install/  no-index

阻止pip通过网络连接到PyPI的关键字是 no-index。你知道吗

我们的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(不过,如果在驾驶室中找不到满足依赖项的轮子,它会搜索web)。你知道吗

配套工具是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

这将导致包的控制盘及其依赖项放置在控制盘文件夹中。你知道吗

相关问题 更多 >