繁体   English   中英

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

[英]python vscode ImportError: No module named simplejson

我在我的代码中导入了 simplejson,并使用 python3 使用 pip install simplejson 进行了安装,所以当我检查时,它在我打开文件的终端中完美运行,但是当我尝试在 VScode 中构建时,它显示了一个错误,例如,请参阅此错误链接

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

回溯(最近一次调用最后一次):文件“/Users/Tony/Documents/python3.9/helloworld.py”,第 1 行,在 import simplejson as json ImportError: No module named simplejson The terminal process "/bin/bash'- c', 'python /Users/Tony/Documents/python3.9/helloworld.py'" 无法启动(退出代码:1)。

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

我已经激活了虚拟环境在此处输入图像描述,我正在使用我最近激活的最后一个。

请帮我找出错误。 我真的不知道在哪里修复谢谢

我已经复制了这个过程,希望以下步骤可以帮助你

1.激活venv并安装simplejson

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

在此处输入图片说明

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:运行任务;

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM