So after much searching I found a way to get gunicorn to play nice with vscode using the following launch.json
"version": "0.2.0",
"configurations": [
{
"name": "Python: Run Debug",
"cwd": "${workspaceFolder}/dir/dir2",
"type": "python",
"request": "launch",
"program": "/Users/me/.virtualenvs/dir/bin/gunicorn",
"args": ["--bind 0.0.0.0:6543", "-w=1", "--paste=local.ini" ],
"console": "integratedTerminal",
"justMyCode": false,
"purpose": ["debug-in-terminal"],
"gevent": true,
"env": {
"GEVENT_SUPPORT": "True",
"PYTHONUNBUFFERED":"1",
"OBJC_DISABLE_INITIALIZE_FORK_SAFETY":"YES",
"PYDEVD_LOAD_NATIVE_LIB": "0",
"PYDEVD_USE_CYTHON":"0"
}
}
]
}
Now this makes the server run but it outputs no variables, it doesn't stop at any breakpoints, and I can't watch anything. Basically, the whole left pane is completely empty.
Has anyone dealt with this successfully before?
Related
I try to debug my python script in VSCode, but it failed to stop at the breakpoint.
I click the debug button, but it seems like nothing happends. The codes never stop at my breakpoint!
Here's my launch.json. I use anaconda virtual envs as interpreter.
Please help me out, thanks!!!
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"pythonPath": "/home/linda/.conda/envs/py3/bin/python",
"justMyCode": false
}
]
}
I am trying to find a way to give current file as argument for module. I couldn't find it anywhere so I'm trying stackoverflow
{
"name": "Python: Synapse",
"type": "python",
"request": "launch",
"module": "projFolder.targetModule",
"console": "integratedTerminal"
}
Manually specifying the module argument such as above example, works. But thinking of doing that for every each file wanted me to automate it. I've tried ${file}, but it gives the file path not the module. So it didn't work. How can I launch current current file as module?
ps: answer from https://stackoverflow.com/a/57416114/6088796, but I modify a litter
add something like this to your launch.json, but if you want to run multi-module(in a different place, the only way you can do is using multi configuration, or use a plugin(see below)
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "yourmodule.${fileBasenameNoExtension}",
"stopOnEntry": true
},
You can use the extension Command Variable to get this relative directory with dot separator.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module CmdVar",
"type": "python",
"request": "launch",
"console": "integratedTerminal",
"module": "${command:extension.commandvariable.file.relativeDirDots}.${fileBasenameNoExtension}",
}
]
}
I have installed Visual Studio Code with the Python extension in Linux Manjaro. When I try to launch a Python script, the external terminal opens but after 5s I get an error message in a window telling me "timeout" and my script doesn't launch.
I've seen this post with the same problem on Windows 10 but the fix doesn't seem to work on Manjaro. Any idea?
Here is my launch.json file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "enter-your-module-name-here",
"console": "integratedTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/IA_TD2.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"
},
{
"name": "Python: Current File (None)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "none"
}
]
}
Unfortunately VSCode is not compatible with every terminal and it seems not (yet) compatible with your Linux Manjaro installation with KDE Desktop Environment.
Switching to another terminal will surely solve this (i.e. GNOME Terminal). I'm not sure, if the gnome-terminal package is aviable without installing the GNOME Desktop Environment.
Here is a good solution how you can do this without reinstalling the whole OS.
As I can't give input in the debug console, I'm trying to run the debugger in External terminal in VS Code.
This is the part of launch.json config file for external terminal.
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"console": "externalTerminal",
"env": {},
"externalConsole": true,
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
},
I added the "externalConsole": true part as they said here and I tried with or without that statement.
I get this error,
Debug adapter process has terminated unexpectedly
I tried the docs and the IntelliSense in the json file, but I can't understand and get it to work.
Adding "console": "externalTerminal", to the debug configuration file worked fine on Linux!
I am using windows, however, this should fix your problem.
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "C:/Users/Zac/Anaconda3/python.exe",
"program": "${file}",
"cwd": "",
"console": "externalTerminal",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
You need to correctly add a path to your python.exe location in the "pythonPath" line.
Also, take out the "WaitOnAbnormalExit" and "WaitOnNormalExit" from "debugOptions" and just use "RedirectOutput". Remove "externalConsole": true from the code.
Everything else should stay the same.
Hope that helps.
Cheers.
Also remember to put correct value for external terminal location in :
terminal.external.windowsExec
I can't figure out why vscode debugger is not working. I tried everything, but the breakpoints are still not working. Has anyone had a similar problem, and solved it?
My lauch.json file just for reference:
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
"stopOnEntry": true,
Set this to false