python,在vs cod中导入模块

2024-09-28 21:31:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我为python安装了cocos2d,示例运行良好

但是当我将python文件移到visual studio代码中选择的文件夹中时,它只是说找不到名为cocos的模块。

我想我需要更改launch.json中的设置,但我不知道如何更改。

我只上传launch.json文件的一部分。

{
"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"
        ]
    },

Tags: 模块文件代码name文件夹json示例version
1条回答
网友
1楼 · 发布于 2024-09-28 21:31:06

您需要修改settings.json中的python.pythonPath设置以指向此解释器,如下所示: "python.pythonPath":"C:/Users/Sanghun/AppData/Local/Programs/Python/Python35-32/python.exe"

或者您可以启动命令'Select Workspace Interpreter'(https://github.com/DonJayamanne/pythonVSCode/wiki/Python-Path-and-Version#selecting-an-interpreter

最后一个注意事项是,您可能希望将launch.json中的更改还原为以下内容(防止您必须在两个位置指定路径): "pythonPath": "${config.python.pythonPath}",

相关问题 更多 >