pip永久更換下載函數庫的鏡像源方式:
在python安裝文件夾下,找到>lib文件夾>site-packages文件夾>pip文件夾>models文件夾下的index.py,編輯修改其最後一句代碼:
PyPI = Index('https://pypi.python.org/')
以上代碼修改爲:
PyPI = Index('https://pypi.tuna.tsinghua.edu.cn/')
以上使用的是清華鏡像庫:(注意不要加: /simple)。修改後保存即可。
還有一些版本的python的pip文件路徑稍有不同,但修改是一樣:
如:D:\python\Lib\site-packages\pip\_internal\models\index.py
原代碼爲:
PyPI = PackageIndex(
'https://pypi.org/', file_storage_domain='files.pythonhosted.org'
)
修改爲:
PyPI = PackageIndex(
'https://pypi.tuna.tsinghua.edu.cn/', file_storage_domain='files.pythonhosted.org'
)
pipenv永久更換下載函數庫的鏡像源方式:
創建虛擬環境後,會在C盤用戶文件夾下存放2個文件,一個是Pipfile文件,另一個是Pipfile.lock文件。
先以文本(記事本)的形式打開Pipfile文件,將裏面的:
url = "https://pypi.org/simple" 更改爲:url = "https://pypi.tuna.tsinghua.edu.cn/simple" (即替換下載鏡像源)。
同理,以文本形式打開Pipfile.lock文件。將url的對應值修改爲:"url": "https://pypi.tuna.tsinghua.edu.cn/simple"
保存後退出即可。