vscode在启动python调试时,要导入numpy模块,而且非常确定numpy已经安装了,但还是提示找到numpy模块

Exception has occurred: ImportError


IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "C:\Users\haijun.zhang1\Anaconda3\python.exe"
  * The NumPy version is: "1.20.1"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: 找不到指定的模块。

按照网上说的方法,在setting.json中设置了Python的路径,
在launch.json中设置了env

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "program": "${file}",
            "pythonPath": "${command:python.interpreterPath}",
            "cwd": "${workspaceRoot}",
            "env": {"PYTHONPATH":"${workspaceRoot}"},
            "envFile": "${workspaceRoot}/.env",
            "console": "integratedTerminal"
        }
    ]
}

但还是不行。
最终解决方法,启动Anaconda Prompt,通过cd指令切换到vscode的目录下,输入code .来启动vscode,就可以正常调试了。

在这里插入图片描述

欢迎关注微信公众号:Quant_Times
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐