PiP常用语法
基础使用语法
普通安装 pip install requests
指定版本安装 pip install robotframework==2.8.7
卸载已安装的库 pip uninstall requests
列出已经安装的库 pip list pip freeze
将已经安装的库列表保存到文本文件中 pip freeze > D:\桌面\install.txt
根据依赖文件批量安装库 pip install -r install.txt
显示所安装包的信息 pip show package pip show -f package
升级指定的包 pip install -U package
库的安装
wheel文件安装方法
- 下载wheel文件
(网址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted)
2.选择自己需要的库,注意与自己python版本匹配和系统
3.安装
安装命令:
使用pip install pillow-4.2xxxxxxx.whl的方式离线进行安装
换源安装
国内的换源网址:
- 阿里云 http://mirrors.aliyun.com/pypi/simple/
- 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
- 豆瓣(douban) https://pypi.douban.com/simple/
- 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
- 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
安装:
-
临时安装,
示例:
pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple(换源网址) -
换源安装:
1.点击此电脑,在最上面的的文件夹窗口输入 : %APPDATA%
2.按回车跳转到以下目录,新建pip文件夹
3.创建pip.ini文件
4.打开文件夹,输入以下内容,关闭即可(注意:源镜像可替换)
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple trusted-host = pypi.tuna.tsinghua.edu.cn