I found the configuration for cpp (https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/Debugger/gdb/Windows%20Subsystem%20for%20Linux.md) and tried to change it for python debugging but it doesn't work. Any suggestion to make it work?
It should be mentioned that the Python extension for VS Code does not officially support WSL yet, but the enhancement request has been made and we do plan on supporting it.
Beyond extensions installations, IDE_PROJECT_ROOTS environment variable also may affect the debugger. For usual WSL standalone python code debugging, making sure this variable is not set (or set to the location of the files) when the VS code is opened helps.
For "step into" debugging of jupyter notebook having the python files path(s) as a part of IDE_PROJECT_ROOTS (for example export IDE_PROJECT_ROOTS="/tmp:/foo_pythonfilespath" set in .bashrc) will help to carry out "step into" python-code debugging in VSCode.
This is now supported and just requires installing the Microsoft Python extension and then to quote the documentation on remote debugging with WSL:
Once you've opened a folder in WSL, you can use VS Code's debugger in
the same way you would when running the application locally. For
example, if you select a launch configuration in launch.json and start
debugging (F5), the application will start on remote host and attach
the debugger to it.
See the debugging documentation for details on configuring VS Code's
debugging features in .vscode/launch.json
Related
I use the RemoteFS extension in VSCode to connect to my remote SSH server. When I open a .py file on the remote server in VSCode, and then add #%% comment to the .py file, I don't get the option to run a Jupyter cell like I would locally.
Has anybody gotten VSCode's Python extension working with it's built-in Jupyter support and the RemoteFS extension?
We had an overly restrictive file check for when we allowed our "Run Cell" commands to show up and it was limiting it to local files only. I've fixed that issue in the following PR here:
https://github.com/Microsoft/vscode-python/pull/4191
I verified that I was seeing the cell commands using Remote FS after that. Sadly this just missed the cutoff for our recent January release, so it won't show up in the extension until later in February. If you want to check out the fix you can access our daily development build here:
https://github.com/Microsoft/vscode-python/blob/master/CONTRIBUTING.md#development-build
That build has the fix already, but it's not the full public release.
When implementing a Visual Studio extension to be used with Python files in the VSCode editor, how can one programmatically get the path of currently selected Python environment?
My guess is that it is done with python.pythonPath, but I can't seem to make it work. If I use that directly within an extension js, it crashes. I also tried:
let python = vscode.extensions.getExtension('python');
python.pythonPath
python.pythonPath is a setting, so you can do this with VSCode's generic settings API (instead of having to rely on the Python extension exposing an API specifically for this):
vscode.workspace.getConfiguration("python").get("pythonPath")
I run Python program which uses couple of source paths on runtime.
I put these rows on my /.bashrc file:
source home/raphael/kaldi/aspire/s5/cmd.sh
source home/raphael/kaldi/aspire/s5/path.sh
So when I'm running from terminal everything works fine and Python manage to locate paths.
However when I'm trying to run through PyCharm for DEBUG purposes mostly it seems that PyCharm can't locate the paths.
Is there anyway to add the paths manually for PyCharm or make it read /.bashrc file. What I am missing?
You can try using the options available in the Run/Debug Configuration settings (Run > Edit Configurations...)
You can set environment variables individually (such as $PATH), or at the bottom is a section to define external tools (scripts) to be run when your Python code is run or debugged. From that sub-section, you could set your bash scripts to be run each time you start debugging.
Alternatively, see if using os.environ would work for your project. Check the docs for more information.
I am using Behave to write BDD tests. The problem I have is that I am unable to create debug environment for these tests. I have successfully created an external tool run environment but that is of little help when I want to use breakpoints and debug the code.
Anyone who uses Lettuce/Behave/Freshen/Cucumber and could let me know how is the debug environment setup?
Found a solution on the Eclipse help page : http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-exttools-running.htm
It is possible to debug python steps (*.py) files in Eclipse IDE.
Belove solution works for:
Windows 7
Behave framework from https://pythonhosted.org
Just make:
Copy behave-script.py to directory that are located .feature files. You can find this file in Python27\Scripts\
In Eclipse add new "Debug as...->Debug Configuration->Python Run"
In a project choose your project
In Main module choose behave-script.py
Hit run and set brakepoints
Although you didn't mention Morelia (another BDD tool for Python) I thing you could try it. It doesn't need any special setup to integrate if traditional unittests works for you. Morelia's documentation: https://morelia.readthedocs.org/en/latest/
In search of a Python debugger I stumbled upon Aptana, which is based on eclipse.
Often, I want to debug a single python script. However, Aptana won't let me run/debug the currently opened file directly.
Instead, it requires me to create a debug/run configuration for each file I would like to run/debug. Alternatively I could create a Python project in Aptana.
But: I don't want to. I just want to be able to run or debug the currently opened file. This way I would like to debug my scripts without being forced to create a project first (for each single script!).
Can it be that hard?
This is because Aptana/Eclipse doesn't "realize" that the file you opened should be debugged using the Python debugger as it's not associated with a Python project/perspective (there's a lot of environment setup when a project is created in Aptana/Eclipse).
The simplest solution, IMO, would be to create a simple sandbox Python project and just stick your files in there to run/debug. Aptana should then realize you're dealing with Python and start running the Python debugger without setup (that's my experience w/ PyDev in Eclipse, at any rate).
See: Run External Python Programs with Eclipse PyDev (note: you really need a project, but your file doesn't need to be in it).