1
votes

Suddenly vsCode on Mac Mojave stopped running any python code. running a simple print(1) produces the following error:

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

Traceback (most recent call last): File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/ptvsd_launcher.py", line 45, in main(ptvsdArgs)

File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/main.py", line 265, in main wait=args.wait)

File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/main.py", line 258, in handle_args debug_main(addr, name, kind, *extra, **kwargs)

File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_local.py", line 45, in debug_main run_file(address, name, *extra, **kwargs)

File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_local.py", line 79, in run_file run(argv, addr, **kwargs)

File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_local.py", line 140, in _run _pydevd.main()

File "/Users/sammy/.vscode/extensions/ms-python.python-2018.12.1/pythonFiles/lib/python/ptvsd/_vendored/pydevd/pydevd.py", line 1936, in main if setup['cmd-line']: TypeError: 'NoneType' object is not callable

I am using the first option this launch.json file

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

I removed the python extension and reinstalled it but that didn't help. Thanks

2

2 Answers

0
votes

VSCode somehow lost the python.pythonPath. Everything worked after setting to to usr/local/bin/python3 or selecting the correct environment from VSCode status bar.

0
votes

Its a temporary Work around but it worked for me, i commented the lines

if setup['cmd-line']:
        debugger.wait_for_commands(globals)

enter image description here

also should try github discussion