Python pip 国内镜像大全及使用办法

Python pip 国内镜像大全及使用办法

一、国内镜像

清华
https://pypi.tuna.tsinghua.edu.cn/simple
豆瓣
pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com '模块版本'
阿里云
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com '模块
版本'
中国科学技术大学
pip install -i http://pypi.mirrors.ustc.edu.cn/simple/ --trusted-host pypi.mirrors.ustc.edu.cn '模块版本'
华中理工大学
pip install -i http://pypi.hustunique.com/simple/ --trusted-host pypi.hustunique.com '模块
版本'
山东理工大学
pip install -i http://pypi.sdutlinux.org/simple/ --trusted-host pypi.sdutlinux.org '模块==版本'

二、使用办法

1、临时使用,添加“-i”或“--index”参数

pip install django==1.11.9 -i https://pypi.douban.com/simple/

2、配制成默认的

在你的“C:\Users\你的用户名\”目录下创建“pip”目录,“pip”目录下创建“pip.ini”文件(注意:以UTF-8 无BOM格式编码);
“pip.ini”文件内容:

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

3、注意:

1、trusted-host 选项为了避免麻烦是必须的,否则使用的时候会提示不受信任,或者添加“--trusted-host=mirrors.aliyun.com”选项;
2、有网页提示需要创建或修改配置文件(linux的文件在~/.pip/pip.conf,windows在%HOMEPATH%\pip\pip.ini),至少Windows7下“%HOMEPATH%\pip\pip.ini”这个目录是不起作用的。

三、在线下载模块离线安装包以及依赖包

# 在线下载离线安装包以及依赖
pip download 你的包名 -d "下载的路径(windows下双引号来表示文件夹)"

# 离线自动安装安装包以及依赖
conda create -n CasRel python=3.6.5
pip install -r requirements.txt --no-index --find-links=./pip_pkgs

四、安装模块遇到的问题

1、执行python -m pipreqs .
报错:No module named pipreqs.__main__; 'pipreqs' is a package and cannot be directly executed
解决方案:用该条命令代替,命令为:python -m pipreqs.pipreqs .
posted @ 2019-11-06 09:55  LBZHK  阅读(4125)  评论(0编辑  收藏  举报