操作系统 : CentOS7.5.1804_x64

Python 版本 : 3.6.8

1、使用pip在线安装

1.1 安装单个package

格式如下:

pip install SomePackage

示例如下:

比如:pip install scipy
或者指定版本安装:pip install scipy==1.3.

1.2 安装多个package

示例如下:

pip install -r req.txt

req.txt 可以通过以下命令获取:

pip freeze > req.txt

1.3 在线安装的其它问题

1.3.1 代理问题

如果需要通过代理安装,可以使用如下格式:

pip --proxy=ip:port install SomePackage

1.3.2 pip源问题

如果pip源太慢,可以更换pip源,有以下两种方式:

方式一:通过修改参数临时修改pip源

比如使用阿里云的pip源:

pip install Sphinx -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

方式二:通过修改配置文件永久修改pip源

文件: ~/.pip/pip.conf

比如使用阿里云的pip源:

[admin@localhost .pip]$ cat ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
extra-index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com [admin@localhost .pip]$

也可以使用自建pip源,或者其它公开pip源,比如:

阿里云 http://mirrors.aliyun.com/pypi/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

Windows对应文件:

C:\Users\用户名\AppData\Roaming\pip\pip.ini

2、从源码安装

示例如下:

git clone https://github.com/sphinx-doc/sphinx
cd sphinx
pip install .

3、从 whl 文件安装

格式如下:

pip install SomePackage.whl 

其它

1、pip下载离线安装包

命令示例:

下载命令:
pip download -d /tmp/packs -r requirement.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com 安装命令:
pip install --no-index --find-links=/tmp/packs -r requirement.txt

本文github地址:

https://github.com/mike-zhang/mikeBlogEssays/blob/master/2019/20190730_使用pip安装python库的几种方式.rst

欢迎补充

最新文章

  1. Android入门(十):界面的布局方式及其实际应用
  2. sass的视频教程
  3. paper 35 :交叉验证(CrossValidation)方法思想
  4. 用Grunt搭建基于LESS的前端html开发框架
  5. 17173php招聘
  6. 【转】C#自定义控件:WinForm将其它应用程序窗体嵌入自己内部
  7. Openjudge-NOI题库-简单算术表达式求值
  8. javascript中函数的call,apply及bind方法
  9. ubuntu如何实现访问实际网络中windows共享文件夹
  10. Spring学习之装配Bean
  11. 用Codility测试你的编码能力
  12. jQuery之标签操作和返回顶部、登录验证、全选反选、克隆示例
  13. Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded
  14. Java基础——Ajax(三)
  15. redis参数改进建议
  16. 逻辑回归 logit
  17. JVM学习记录-Java内存模型(一)
  18. 用highcharts展现你的数据
  19. 反面教材 构造构造 json 数据
  20. 常用的API接口

热门文章

  1. 解决div用了position: fixed后滚动条显示不完整的问题
  2. 前台get传递含中文数据到后台出现中文乱码
  3. iOS 类别 类扩展 简要说明
  4. Java使用iBatis批量插入数据到Oracle数据库
  5. PHP7.3安装event扩展
  6. JS---案例:点击按钮设置div背景色渐变
  7. 换了网线异常了,CRS无法正常启动,clssnmSendingThread: sending status msg to all nodes
  8. Appium(六):元素定位
  9. 0基础-scp命令一学就会
  10. SpringCloud路由网关Zuul