Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2840497
  • 博文数量: 348
  • 博客积分: 2907
  • 博客等级: 中校
  • 技术积分: 2272
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-12 09:16
个人简介

专注 K8S研究

文章分类

全部博文(348)

文章存档

2019年(22)

2018年(57)

2016年(2)

2015年(27)

2014年(33)

2013年(190)

2011年(3)

2010年(14)

分类: 系统运维

2018-12-29 15:44:06

1.下载单个文件
例如:

pip3 download requests -d /tmp/py3
Collecting requests
  Using cached
  Saved /tmp/py3/requests-2.21.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
  Using cached
  Saved /tmp/py3/certifi-2018.11.29-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests)
  Using cached
  Saved /tmp/py3/idna-2.8-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Using cached
  Saved /tmp/py3/chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3<1.25,>=1.21.1 (from requests)
  Using cached
  Saved /tmp/py3/urllib3-1.24.1-py2.py3-none-any.whl
Successfully downloaded requests certifi idna chardet urllib3

ls /tmp/py3/
certifi-2018.11.29-py2.py3-none-any.whl  chardet-3.0.4-py2.py3-none-any.whl  idna-2.8-py2.py3-none-any.whl  requests-2.21.0-py2.py3-none-any.whl  requirements.txt  urllib3-1.24.1-py2.py3-none-any.whl

2.下载多个文件
比如下载 django 1.8.11版本和simplejson 3.14.0版本的包
那么就将所需的包写入  requirement.txt
那么我的requirement.txt内容就是:
django==1.8.11
simplejson==3.14.0
如果还需要其他的包可以依次写,注意一定要写清楚自己所需的版本号避免使用的时候出错。
例如:想将包放在\home\packs目录下
那么就在命令行窗口输入:pip download -d \home\packs -r requirement.txt


3.离线安装

下载指定的包到指定文件夹。
          pip list #查看安装的包
          pip freeze > requirements.txt   将已经通过pip安装的包的名称记录到 requirements.txt文件

安装指定的离线包     
 pip install --no-index --find-links=d:/python27/packs/ falsk    ##安装单个包 
 pip install --no-index --find-links=d:/python27/packs/  -r requirements.txt  ##安装多个包

查看安装路径
pip show requests
Name: requests
Version: 2.7.0
Summary: Python HTTP for Humans.
Home-page:
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: 
Required-by: docker, docker-py, docker-compose
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


指定安装路径
 /usr/local/bin/pip2 install numpy --target=/usr/local/lib/python2.7/site-packages


阅读(5332) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~