pip镜像源Python入门之pip永久镜像源的配置方法pip镜像源配置

目录
  • 国内镜像源
  • 1.临时镜像源的安装命令
  • 2.永久镜像源的配置技巧
  • 3.pip config常用命令
  • 4.技巧补充

国内镜像源

国内多少好用的Python镜像服务器地址:

1. 清华大学镜像站:https://pypi.tuna.tsinghua.edu.cn/simple/

2. 阿里云镜像站:https://mirrors.aliyun.com/pypi/simple/

3. 中科大镜像站:https://pypi.mirrors.ustc.edu.cn/simple/

4. 中国科技大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/

5. 中国科学技术大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/

6. 华中科技大学镜像站:https://pypi.hustunique.com/

1.临时镜像源的安装命令

pip install -i +国内镜像地址 +模块名称 或 pip install +模块名称 -i +国内镜像地址

pip install pyperclip -i https://pypi.tuna.tsinghua.edu.cn/simple

2.永久镜像源的配置技巧

这样不用每次安装库的时候+镜像地址,省事不少。

A、开门见山说,需要确定一个可靠能用的镜像源。一些常用的Python镜像源包括阿里云、清华大学和豆瓣等。可以在官方网站上查找具体的镜像源地址。

B、在终端或cmd命令提示符中设置指定的镜像源地址:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

C、配置好之后,现在可以加速安装第三方模块了。在终端或命令提示符中输入下面内容命令:(此时就自动带一个镜像源,pip install +库名即可)

pip install pyperclip

D、查看当前配置的镜像源地址

pip config list

3.pip config常用命令

这些基本用于管理本地和全局配置

列出配置:使用pip config list 命令,可以列出当前pip的所有配置项。

编辑配置:使用pip config edit命令,可以在默认编辑器中编辑当前的配置文件。

设置配置:使用pip config set命令,可以设置或修改配置项的值。例如,pip config set global.proxy http://proxy.example.com:8080。

获取配置:使用pip config get命令,可以获取当前配置项的值。例如,pip config get global.proxy。

删除配置:使用pip config unset命令,可以删除配置项。例如,pip config unset global.proxy。

查看调试信息:使用pip config debug命令,可以查看当前的调试信息。

4.技巧补充

python永久配置阿里云镜像源

在 Python 中配置阿里云镜像源(阿里云 PyPI 镜像)可以显著提升国内下载速度。下面内容是详细配置技巧:

1.临时使用阿里云

在安装包时直接指定阿里云镜像:

pip install 包名 -i https://mirrors.aliyun.com/pypi/simple –trusted-host mirrors.aliyun.com

2.永久配置阿里云源

技巧一:修改 pip 配置文件(推荐)

Windows 体系:

1. 打开文件资源管理器,输入路径:

%APPDATA%pip

2. 创建或编辑 `pip.ini` 文件,添加:

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

Linux/macOS 体系:

1. 创建或编辑配置文件:

mkdir -p ~/.pip && nano ~/.pip/pip.conf

2. 写入下面内容内容:

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

技巧二:命令行一键配置

pip config set global.index-url https://mirrors.aliyun.com/pypi/simplepip config set global.trusted-host mirrors.aliyun.com

验证配置是否生效

pip config list

输出应包含:

global.index-url=&039;https://mirrors.aliyun.com/pypi/simple&039;
global.trusted-host=&039;mirrors.aliyun.com&039;

恢复默认源

pip config unset global.index-urlpip config unset global.trusted-host

阿里云镜像源地址

HTTP:http://mirrors.aliyun.com/pypi/simple
HTTPS:https://mirrors.aliyun.com/pypi/simple

windows下永久配置pip镜像源

%userprofile%或%homepath%下新建目录pip

在pip目录下,新建文件pip.ini

文件内容如下:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com
timeout = 6000

到此这篇关于Python入门之pip永久镜像源的配置技巧的文章就介绍到这了,更多相关Python pip永久配置镜像源内容请搜索风君子博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持风君子博客!

无论兄弟们可能感兴趣的文章:

  • Python配置pip国内镜像源的实现
  • Python-pip配置国内镜像源的安装方式
  • Python-pip配置国内镜像源快速下载包的技巧详解
  • Python?Anaconda以及Pip配置清华镜像源代码示例
  • pythonpip配置国内镜像源的技巧(永久和临时)
版权声明

为您推荐