pip install 『包名』 -i 『網址』
如:
import os
command = "pip install opencv-contrib-python -i http://pypi.mirrors.ustc.edu.cn/simple
os.system(command)
『網址』中的內容可以是以下站點:
阿里雲 http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
如果報錯
可以使用:
import os
command = "pip install opencv-contrib-python -i http://pypi.mirrors.ustc.edu.cn/simple --trusted-host pypi.mirrors.ustc.edu.cn"
os.system(command)