制作离线pip源

一、下载需要的pip包

通过一下两种方式下载:
1、[root@ecs ~]# pip download numpy -d /opt/pip
2、[root@ecs ~]# pip download  -d /opt/pip -r requirements.txt  ##将要下载的包写入requirements.txt文件

也可以通过一下命令或得系统中已经安装的pip包,并写入到requirements.txt
[root@ecs ~]# pip freeze > requirements.txt

#####举例如下:
[root@ecs ~]# pip download numpy -d /opt/pip
Collecting numpy
  Using cached https://files.pythonhosted.org/packages/3a/5f/47e578b3ae79e2624e205445ab77a1848acdaa2929a00eeef6b16eaaeb20/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl
  Saved /opt/pip/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl
Successfully downloaded numpy
[root@ecs ~]# ll /opt/pip/
total 16612
-rw-r--r-- 1 root root 17008014 Dec 24 16:42 numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl

二、安装离线包

通过两种方式安装
1、pip install   --no-index   --find-links=/opt/pip  numpy  ##指定pip包名称
2、pip install   --no-index   --find-links=/opt/pip -r requirements.txt  ##将要安装的包写入requirements.txt文件中

举例如下:
[root@ecs ~]# cat requirements.txt 
numpy==1.16.6
[root@ecs ~]# pip install --no-index  --find-links=/opt/pip -r requirements.txt 
Looking in links: /opt/pip
Processing /opt/pip/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.16.6
[root@ecs ~]# pip list | grep numpy
numpy                            1.16.6   
[root@ecs ~]# 
[root@ecs ~]# 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值