在使用
要查看已启用的扩展列表和
问题是什么,如何解决?
环境信息: Windows 10 x64,Anaconda 10/19(虚拟环境),VSCode 1.41.1
复现步骤:
import numpy as np
命令时出现错误;在终端中直接输入命令可以正常工作,但是通过 Code Runner 运行失败。下面是我复现的步骤。
import sys; print(sys.version)
命令的输出结果为 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)]
。VSCode 显示正在运行预期的 Python 解释器:Python 3.7.5 64-bit ('vsc': conda)
在左下角的面板中(请参见剪辑)。 -- 简短的视频演示。要查看已启用的扩展列表和
settings.json
的内容,请参阅相关 Git。问题是什么,如何解决?
环境信息: Windows 10 x64,Anaconda 10/19(虚拟环境),VSCode 1.41.1
复现步骤:
conda create --name vsc
conda activate vsc
conda install python==3.7.5
conda install numpy
# in VSCode: import numpy as np, etc
完整的回溯信息:
Traceback (most recent call last):
File "D:\Anaconda\envs\vsc\lib\site-packages\numpy\core\__init__.py", line 17, in <module>
from . import multiarray
File "D:\Anaconda\envs\vsc\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
from . import overrides
File "D:\Anaconda\envs\vsc\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Desktop\School\Python\vscode\HelloWorld\app.py", line 1, in <module>
import numpy as np
File "D:\Anaconda\envs\vsc\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "D:\Anaconda\envs\vsc\lib\site-packages\numpy\core\__init__.py", line 47, in <module>
raise ImportError(msg)
ImportError:
编辑:根据James的建议,将以下内容添加到settings.json
中:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/K", "D:\\Anaconda\\Scripts\\activate.bat D:\\Anaconda"],
"python.condaPath": "D:\\Anaconda\\Scripts\\conda.exe"
Ctrl + Shift + P
-> 选择解释器
-> Python 3.7.5 64位 ('vsc': conda)
- OverLordGoldDragon