In the case of the internal network (not connected to the public network), use pip to install the python dependency package

Foreword:

哎,最近又有恶心的场景。
甲方给了几台内网的虚拟机,让同事只能远程开发,并且是只能通过堡垒机链接进去。
这样的话,我之前使用的网络转发就无法安装所需依赖了。毕竟人不在现场,甲方的限制又比较多。所以只能看看pip是如何才能离线安装。下面是总结。

step:

One: Prepare a virtual machine that can connect to the external network with the same environment as the internal network virtual machine, the python version, and the operating system version are consistent

// An highlighted block
var foo = 'bar';

Two: Using pip on a machine that can link to the external network will depend on the whl file of the package (it may also be in tar.gz or tar format, but it will not affect subsequent use)

使用命令:pip download package_name -d "文件保存路径"
如: 我要将pandas下载到本地的某个文件中
pip download pandas -d C:\Users\hwz\Desktop\project
使用此命令时,可以看到pip将pandas的依赖如:numpy,six,pytz等等都下载了下来。

如需要批量下载则使用命令:
pip download -r requirements.txt -d "文件保存路径"

如需使用镜像批量下载:
pip download -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt -d "文件保存路径"

pandas dependency download
insert image description here

Batch download
insert image description here

Three: Upload it to the intranet virtual machine and install it using pip.

使用命令:
	pip install ***.whl
如:
	pip install pandas-1.3.5-cp37-cp37m-win_amd64.whl

如果有以下提示则按照其所依赖的包逐个安装即可。

insert image description here

Special case

一些包会是如下tar或者tar.gz格式,不影响正常使用直接使用命令:
	如:pip install comtypes-1.1.10.tar.gz   逐个安装即可
	下面已经示范

insert image description here

insert image description here

Damn, Party A is really disgusting. I'm a fucking pure cow and a pure force. wipe.
Hey, try hard.
Although he scolded, he still had to work in the middle of the night.

Guess you like

Origin blog.csdn.net/weixin_43441262/article/details/130978959