欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python入門之pip永久鏡像源的配置方法

 更新時間:2025年05月13日 09:08:08   作者:認真寫程序的強哥  
這篇文章主要為大家詳細介紹了國內(nèi)幾個好用的Python鏡像服務器地址,如清華,阿里云等,還說明了臨時和永久鏡像源的配置方法,希望對大家有一定的幫助

國內(nèi)鏡像源

國內(nèi)幾個好用的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 +國內(nèi)鏡像地址 +模塊名稱 或 pip install +模塊名稱 -i +國內(nèi)鏡像地址

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

2.永久鏡像源的配置方法

這樣不用每次安裝庫的時候+鏡像地址,省事不少。

A、首先,需要確定一個可靠能用的鏡像源。一些常用的Python鏡像源包括阿里云、清華大學和豆瓣等??梢栽诠俜骄W(wǎng)站上查找具體的鏡像源地址。

B、在終端或cmd命令提示符中設置指定的鏡像源地址:

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

C、配置好之后,現(xiàn)在可以加速安裝第三方模塊了。在終端或命令提示符中輸入以下命令:(此時就自動帶一個鏡像源,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。

查看調(diào)試信息:使用pip config debug命令,可以查看當前的調(diào)試信息。

4.方法補充

python永久配置阿里云鏡像源

在 Python 中配置阿里云鏡像源(阿里云 PyPI 鏡像)可以顯著提升國內(nèi)下載速度。以下是詳細配置方法:

1.臨時使用阿里云

在安裝包時直接指定阿里云鏡像:

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

2.永久配置阿里云源

方法一:修改 pip 配置文件(推薦)

Windows 系統(tǒng):

1. 打開文件資源管理器,輸入路徑:

  %APPDATA%\pip\

2. 創(chuàng)建或編輯 `pip.ini` 文件,添加:

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

Linux/macOS 系統(tǒng):

1. 創(chuàng)建或編輯配置文件:

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

  2. 寫入以下內(nèi)容:

     [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/simple
pip config set global.trusted-host mirrors.aliyun.com

驗證配置是否生效

pip config list

輸出應包含:

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

恢復默認源

pip config unset global.index-url
pip 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

文件內(nèi)容如下:

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

到此這篇關于Python入門之pip永久鏡像源的配置方法的文章就介紹到這了,更多相關Python pip永久配置鏡像源內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論