微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。