python的pip配置的國內(nèi)鏡像的實現(xiàn)
常用國內(nèi)鏡像源列表
- 清華大學(xué):https://pypi.tuna.tsinghua.edu.cn/simple
- 阿里云:https://mirrors.aliyun.com/pypi/simple
- 中科大:https://pypi.mirrors.ustc.edu.cn/simple
- 華為云:https://repo.huaweicloud.com/repository/pypi/simple
- 豆瓣:https://pypi.doubanio.com/simple
Windows系統(tǒng)配置方法(PowerShell)
1. 臨時使用鏡像源 :
pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple
2. 永久配置鏡像源 :
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
執(zhí)行示例:
C:\Users\admin>pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple Writing to C:\Users\admin\AppData\Roaming\pip\pip.ini

Writing to ... 表示 pip 已經(jīng)將新的配置寫入到指定的配置文件中。在 Windows 系統(tǒng)中,用戶級別的 pip 配置文件路徑通常是:
C:\Users\你的用戶名\AppData\Roaming\pip\pip.ini
你看到的路徑完全正確,說明配置成功生效。
3. 驗證配置是否生效 :
pip config list
執(zhí)行示例:

C:\Users\admin>pip config list global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'
解決SSL驗證問題(需要時)
pip install package_name --trusted-host pypi.tuna.tsinghua.edu.cn
執(zhí)行示例:

C:\Users\admin>pip install package_name --trusted-host pypi.tuna.tsinghua.edu.cn Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting package_name Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/5f/6690d5f0bad41818063e3f436c101deff0f243adede1d23642deb607349d/package_name-0.1.tar.gz (782 bytes) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: package_name Building wheel for package_name (pyproject.toml) ... done Created wheel for package_name: filename=package_name-0.1-py3-none-any.whl size=1249 sha256=42d4d6c6fdbbb196c2a799d4ad10002437e5ebf1f518623cb353a5af2f09def1 Stored in directory: c:\users\admin\appdata\local\pip\cache\wheels\82\c3\1b\f14c30dafba2a2afde388a04dac07caef2d1b03e22356314a3 Successfully built package_name Installing collected packages: package_name Successfully installed package_name-0.1
常用組合命令示例
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
requirements.txt文件內(nèi)容
這里面放著項目需要安裝的所有的依賴包;
torch<=2.3.0 torchaudio modelscope huggingface huggingface_hub funasr>=1.1.3 numpy<=1.26.4 gradio fastapi>=0.111.1
到此這篇關(guān)于python的pip配置的國內(nèi)鏡像的實現(xiàn)的文章就介紹到這了,更多相關(guān)python pip配置國內(nèi)鏡像內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
執(zhí)行Django數(shù)據(jù)遷移時報 1091錯誤及解決方法
這篇文章主要介紹了執(zhí)行Django數(shù)據(jù)遷移,報錯 1091,需要的朋友可以參考下2019-10-10
Python中類型關(guān)系和繼承關(guān)系實例詳解
這篇文章主要介紹了Python中類型關(guān)系和繼承關(guān)系,較為詳細(xì)的分析了Python中類型關(guān)系和繼承關(guān)系的原理與使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-05-05
PyInstaller將Python腳本打包為可執(zhí)行文件的完整指南
PyInstaller?是一個功能強(qiáng)大的工具,可以將?Python?腳本及其所有依賴項打包成一個獨立的可執(zhí)行文件,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下的相關(guān)資料2026-01-01

