当我在用vscode编译Python 时候,发现无法编译通过,output显示ModuleNotFoundError: No module named 'matplotlib'
,这是因为我在代码中使用了这个库,import matplotlib.pyplot as plt
,但我电脑中并没有这个库,因此我便在cmd 中安装这个调用matlab同样功能的库,但发现很慢。
后面发现,只需要在原本的安装命令后面加上一行代码
-i https://pypi.tuna.tsinghua.edu.cn/simple
就可以了。
例如原本是在cmd 中输入
pip install Matplotlib
结果慢得要死,然后输入
pip install Matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple
速度快到飞起。
这只是清华库,也可以换成其他库
清华
https://pypi.tuna.tsinghua.edu.cn/simple/
中科大
https://pypi.mirrors.ustc.edu.cn/simple/
阿里云
https://mirrors.aliyun.com/pypi/simple/
豆瓣
http://pypi.douban.com/simple/