简体   繁体   中英

python vscode ImportError: No module named simplejson

i have import simplejson in my code, and installed using pip install simplejson using python3 so as i checked, it perfectly runs in my terminal opening the file but when i try to build in VScode, it shows an error like, see the error in this link as

`> Executing task: python /Users/Tony/Documents/python3.9/helloworld.py <

Traceback (most recent call last): File "/Users/Tony/Documents/python3.9/helloworld.py", line 1, in import simplejson as json ImportError: No module named simplejson The terminal process "/bin/bash '-c', 'python /Users/Tony/Documents/python3.9/helloworld.py'" failed to launch (exit code: 1).

but it still runs on my terminal. and if i check the pip list, simplejson is still there and i also tried to use different version of python too.

and I have activated the virtual environment enter image description here and i am using the last one which i recently activated.

please help me to find the error. i don't really know where to fix thanks

I've reproduced this process and hope the following steps could help you

1.Activate the venv and install simplejson ;

2.Run the helloworld.py in Terminal to make sure the script no error;

在此处输入图片说明

3.Configure the tasks.json , pay attention to use the venv's 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:Run Task;

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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