创建项目后,尝试安装第三方库的时候,Available Package为空;
环境配置情况:
python packages中的 “Python Package Respositories” 也已经添加了国内的镜像;
进入 Setting - Python Interpreter - Available Package中,还是为空,刷新时会提示超时 “connect timed out”
最后通过在 终端中 输入:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
通过查询pip的版本信息确认:
pip -v config list
如果成功(出现最后一行,代表成功):
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\chend\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\chend\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'D:\Python\PythonProjects\SmartHome\.venv\pip.ini'
global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'