报错描述
- anaconda prompt中,import numpy正常
- vscode中,import numpy报错:DLL load failed
报错原因
vscode未能正确初始化环境变量
解决方法
打开vscodesettings.json
文件
(type) CTRL + SHIFT + P
(search for:) open settings
(click:) Preferences: Open Settings (JSON)
添加三行
{
... # any other settings you have already added (remove this line)
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "x:\\xxx\\Anaconda3\\Scripts\\activate.bat x:\\xxx\\Anaconda3"],
"python.condaPath": "x:\\xxx\\Anaconda3\\Scripts\\conda.exe"
}