安裝 好了 python 以后 一件比較重要的事情就是 pip 換源了。
一般 Python 會從 國外 安裝第三方包,網速相對而言就比較慢,所以 國內用戶會選擇換源啥的。
網上有很多換源的教程,還有詳細的解釋為啥要換源。如何一次換源,永久換源之類的。
一般就是 找到 對應文件夾, 創建一個文件,然后 復制 粘貼 一串代碼。 就可以了。
教程呢 基本都是一樣,我就干脆 弄成一個 腳本,或者是 exe 了。 用戶只要點一下 就okk 了。
注意 : 只適合 windows
注意 : 只適合 windows
注意 : 只適合 windows
注意 : 只適合 windows
exe 文件 下載
Python 腳本:
import getpass
import os
content = """[global]
index-url=http://pypi.douban.com/simple/
extra-index-url=
https://mirrors.aliyun.com/pypi/simple/
https://pypi.mirrors.ustc.edu.cn/simple/
https://pypi.tuna.tsinghua.edu.cn/simple/
http://pypi.mirrors.ustc.edu.cn/simple/
[install]
trusted-host=
pypi.douban.com
mirrors.aliyun.com
pypi.mirrors.ustc.edu.cn
pypi.tuna.tsinghua.edu.cn
pypi.mirrors.ustc.edu.cn
"""
user = getpass.getuser()
work_path = None
if os.path.exists("C:\\users"):
work_path = "C:\\users"
else:
print("用戶文件夾不存在在, 請監測......")
_ = input()
exit()
user_path = os.path.join(work_path, user)
if os.path.exists(user_path):
pip_path = os.path.join(user_path, "pip", "pip.ini")
with open(pip_path, "w") as fp:
fp.write(content)
print("okk, nice, 搞定.....")
else:
print("用戶不存在, 請檢查......")
_ = input()
exit()
_ = input()
有問題,記得聯系我,,
有問題,記得聯系我,,
有問題,記得聯系我,,
有問題,記得聯系我,,
