健康一贴灵,专注医药行业管理信息化

python 换源方法

你现在的做法(每次都在命令后面加 -i https://pypi.tuna.tsinghua.edu.cn/simple)叫作“临时换源”。想要一劳永逸,不用每次都手动敲后缀,我们需要把它设置为“永久换源”
设置永久换源非常简单,你只需要在终端(Terminal)里运行一行命令,让 pip 把它“记在脑子里”就行了。

🛠️ 怎么设置永久镜像源?

第一步:打开你的终端
在 VS Code 或 PyCharm 的下方找到“终端(Terminal)”。
 
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

设置信任该镜像(防止安全警告)
再运行下面这行命令,按下回车:

pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn

可以运行下面这行命令来检查一下:

pip config list

如果出现以下就说明成功了

global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'

install.trusted-host='pypi.tuna.tsinghua.edu.cn'

posted @ 2026-06-18 09:48  一贴灵  阅读(15)  评论(0)    收藏  举报
学以致用,效率第一