直接换清华镜像源,安装时后面跟上安装路径即可 -i https://pypi.tuna.tsinghua.edu.cn/simple
# setup.py
import subprocess
import sys
def install_requirements():
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt', '-i https://pypi.tuna.tsinghua.edu.cn/simple'])
print("依赖安装成功。")
except subprocess.CalledProcessError:
print("依赖安装失败。")
if __name__ == '__main__':
install_requirements()