python vscode ImportError:没有名为simplejson的模块

问题描述

我在我的代码中导入了simplejson,并使用pip进行了安装,并使用python3安装了simplejson。 因此,正如我检查的那样,它可以在我打开文件的终端中完美运行,但是当我尝试在VScode中进行构建时,它会显示错误, see the error in this link

`>执行任务:python /Users/Tony/Documents/python3.9/helloworld.py

回溯(最近通话最近): 文件“ /Users/Tony/Documents/python3.9/helloworld.py”,第1行,在 导入simplejson为json ImportError:没有名为simplejson的模块 终端进程“ / bin / bash'-c','python /Users/Tony/Documents/python3.9/helloworld.py'”无法启动(退出代码:1)。

,但它仍在我的终端上运行。如果我检查了pip列表,则simplejson仍然存在,我也尝试使用其他版本的python。

并且我已经激活了虚拟环境enter image description here 我正在使用最近激活的最后一个。

请帮助我找到错误。我真的不知道该在哪里解决

解决方法

我已复制了此过程,希望以下步骤可以为您提供帮助

1。激活venv并安装simplejson;

2。在终端中运行helloworld.py以确保脚本没有错误;

enter image description here

3。配置tasks.json,注意使用 venv的pythonpath ;

"version": "2.0.0","tasks": [
        {
            "label": "run python file","type": "shell","command": "/venv's pythonpath/ helloworld.py","group": {
                "kind": "test","isDefault": true
            },"problemMatcher": [
                "$tsc"
            ]
        }
    ]

4.Tasks:运行任务;

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...