python中提高pip install速度
2020-03-11 16:36
495 查看
pip install命令默认是用的是python官方源,由于一些客观原因,连接速度很慢,甚至超时中断,到时很多模块安装不上,甚是苦恼!
怎么办?
使用国内镜像源,将以下命令完成拷贝出来,粘贴至记事本中,保存为bat文件,双击执行该批处理文件。
@echo off rem 声明采用UTF-8编码chcp 65001 echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* echo 自动设置pip安装配置文件 echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* set pipFolder=\\pip\\ if exist %userprofile%%pipFolder% ( echo 目录%userprofile%%pipFolder%已存在无需创建 ) else ( echo 创建%userprofile%%pipFolder% md %userprofile%%PiPFolder% ) cd %userprofile%%pipFolder% echo \[global\]>pip.ini ( echo timeout=60 echo index-url=http://pypi.douban.com/simple echo extra-index-url=https://pypi.tuna.tsinghua.edu.cn/simple/ echo \[install\] echo trusted-host=pypi.douban.com echo pypi.tuna.tsinghua.edu.cn echo timeout = 10 )>>pip.ini wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;%userprofile%%pipFolder%pip.ini"
然后再试试pip install命令,绝对飞一般的感觉。
另外给大家一些常用的pip国内源:
阿里云 https://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/
中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/
使用方法
临时生效
使用时加上参数 -i
如:
pip install matplotlib -i https://mirrors.aliyun.com/pypi/simple/
永久生效
1.Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
2.windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。
您可能感兴趣的文章:
相关文章推荐
- Ubuntu16.04 下更换pip镜像源提高pip install 下载速度
- centOS,Ubuntu,python pip 更换国内源,让速度快起来,提高工作效率
- 提高pip install的下载速度
- ubuntu14.0 docker 镜像 pip install python相关的包,下载速度很慢很慢的解决办法
- python中pip使用国内镜像提高安装速度
- 完美解决Python 2.7不能正常使用pip install的问题
- centos6安装python3.5、pip3.5、easy_install-3.5
- 【Python错误】windows下使用pip/easy_install提示Fatal error in launcher: Unable to create process using...
- Centos6.5 安装(更新)python3.5 和pip3.5,easy_install3.5问题
- 利用pypy提高python脚本的执行速度及测试性能 推荐
- pip install 提升速度
- python 安装easy_install和pip
- 采用Psyco实现python执行速度提高到与编译语言一样的水平
- 安装Python 包自动安装工具 easy_install 和pip
- python基础===Windows环境下使用pip install 安装出错"Cannot unpack file"解决办法
- 提高pip下载速度
- pip install mysql-python fails with EnvironmentError: mysql_config not found
- python安装 pip安装 easy_install安装 setuptools安装 virtualenv安装
- Linux(mint)及windows“python导入模块失败(no module ...)”的解决办法【pip install 安装失败】
- Using pip to install Python packages on Anaconda