不再能够在Vscode

时间:2018-12-26 19:23:33

标签: python-3.x visual-studio-code

突然,Mac Mojave上的vsCode停止运行任何python代码。 运行简单的 print(1)会产生以下错误:

  

cd / Users / sammy / Code / python / Socratica; env“ PYTHONIOENCODING = UTF-8”   “ PYTHONUNBUFFERED = 1” python   /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/ptvsd_launcher.py   --default --client --host localhost --port 49677 /Users/sammy/Code/python/Socratica/lambda1.py 1

     

回溯(最近通话最近):文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/ptvsd_launcher.py”,   第45行,在       main(ptvsdArgs)

     

文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/ 主要 .py”,   265行,在主要       wait = args.wait)

     

文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/ 主要 .py”,   第258行,在handle_args中       debug_main(addr,name,kind,* extra,** kwargs)

     

文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_local.py”,   第45行,在debug_main中       run_file(地址,名称,*额外,** kwargs)

     

文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_local.py”,   第79行,在run_file中       运行(argv,addr,** kwargs)

     

文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_local.py”,   _run中的第140行       _pydevd.main()

     

文件   “ /Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py”,   1936年线,主要       如果setup ['cmd-line']:TypeError:' NoneType'对象不可调用

我正在使用这个launch.json文件的第一个选项

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost"
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "enter-your-module-name-here",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "console": "integratedTerminal",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "django": true
        },
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        },
        {
            "name": "Python: Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        }
    ]
}

我删除了python扩展名并重新安装了它,但这没有帮助。 谢谢

2 个答案:

答案 0 :(得分:0)

VSCode不知何故丢失了python.pythonPath。设置为usr / local / bin / python3或从VSCode状态栏中选择正确的环境后,一切正常。

答案 1 :(得分:0)

它是临时解决方法,但对我有用,我评论了这些行

exec

enter image description here

也应该尝试github discussion