简体   繁体   中英

python, import module in vs code

I installed cocos2d for python and the samples worked well

But when I move the python file into the folder that I selected in the visual studio code, it's only saying that it cannot find the module named cocos.

I guess I need to change the setting in the launch.json but I don't know how.

I'll just upload the part of my launch.json file.

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Python",
        "type": "python",
        "request": "launch",
        "stopOnEntry": true,
        "pythonPath": "C:/Users/Sanghun/AppData/Local/Programs/Python/Python35-32/python.exe",
        "program": "${file}",
        "debugOptions": [
            "WaitOnAbnormalExit",
            "WaitOnNormalExit",
            "RedirectOutput"
        ]
    },

You will need to modify the python.pythonPath setting in settings.json to point to this interpreter as follows: "python.pythonPath":"C:/Users/Sanghun/AppData/Local/Programs/Python/Python35-32/python.exe"

Or you could just launch the command 'Select Workspace Interpreter' ( https://github.com/DonJayamanne/pythonVSCode/wiki/Python-Path-and-Version#selecting-an-interpreter )

One last note, you might want to revert the change in launch.json to the following (prevents you from having to specify the path in two places): "pythonPath": "${config.python.pythonPath}",

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