常用pip源
阿里云 [http://mirrors.aliyun.com/pypi/simple/][1]
中国科技大学 [https://pypi.mirrors.ustc.edu.cn/simple/][2]
豆瓣(douban) [http://pypi.douban.com/simple/][3]
清华大学 [https://pypi.tuna.tsinghua.edu.cn/simple/][4]
中国科学技术大学 [http://pypi.mirrors.ustc.edu.cn/simple/][5]
华中理工大学:[http://pypi.hustunique.com/][6]
山东理工大学:[http://pypi.sdutlinux.org/][7]
pip源配置
1. 永久方法(不用每次打上URL)
1)windows文件管理器下输入:%APPDATA%
2)新建pip文件夹,在pip文件夹下新建pip.ini文件
3)输入如下代码并保存
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
2. pip升级
python -m pip install --upgrade pip
3. 检查哪些包需要更新
pip list --outdated
4.
常用pip下载命令
0. 已配置pip源,单独安装
pip install xlrd # 不指定版本
pip install xlrd==1.2.0 # 指定版本
1.通过pip源安装: pip install jupyter -i http://pypi.tuna.tsinghua.edu.cn/simple
使用上述命令出错:
重新执行:pip install jupyter -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
2. 批量安装
1)准备requirements.txt文件
格式如图:
2)执行命令: pip install -r requirements.txt
3.升级指定开源库xlrd: pip install --upgrade xlrd
4.下载源码包安装:
1)进入开源库的setup.py所在文件夹,
2)执行: python setup.py install
5. pip卸载包: pip uninstall 要卸载的包名
6. 生成requirements.txt文件: pip freeze > requirements.txt
7.列出已安装了那些包:
pip freeze
pip list
8. linux和windows下某些命令存在差异,查看帮助可通过
pip --help
常见错误
########################################################################################################################################################################
问题1:pillow下载失败
解决方式:
1.查看pip源是否正常
2.到开源安装包目录下找到pillow相关的如pillow*,PIL文件夹,删除,重新pip安装
C:pythonpython27Libsite-packages
########################################################################################################################################################################
问题2:pip安装开源库,出现SSL关键字相关错误,如下
解决方式:
未给定受信任的源,需要在用户目录下新建pip/pip.ini文件,并添加如下信息
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
disable-pip-version-check = true
timeout = 120
[list]
format = columns
重新下载即可成功。
########################################################################################################################################################################
问题3:python2.7环境下,安装image==1.5.28出现如下问题
ERROR: Could not install packages due to an EnvironmentError: [Errno 22] invalid mode ('wb') or filename:
解决方式:
1.安装 Django>=1.8.17
2.安装image==1.5.28
Django2.0不支持python2.7
########################################################################################################################################################################
问题4:
解决方式:
########################################################################################################################################################################
问题5:
解决方式:
########################################################################################################################################################################