I am running my code in Pycharm from Terminal. Is it possible to debug the code and put breakpoints inside the code during a run from terminal?
I don't know anyway to do this through the terminal, but the way I currently do it is:
Run > Edit Configurations > Add new configuration (the green + button)
Choose Python
Fill out Script path, Parameters, and other configuration fields.
Debug the newly added configuration. (Run > Debug...)
With the right configuration the result should be the same as running the script in a terminal.
I find the above process a little tedious. A PEP 553 breakpoint() might be nicer. It requires Python 3.7 and is not implemented yet. See the related issue.
Even if the program is started outside of PyCharm, we can attach PyCharm debugger to it.
Go to Run -> Attach to process.
This will show a list of python process that are currently running on the system. Select the appropriate process from it.
Now PyCharm debugger is connected to that process. We can add breakpoints and debug it.
There is a way using python console.
To run it: Tools -> python console .. or you can find it at the bottom of the IDE.
Then press on 'Attach debugger' line in the following picture:
Add a breakpoint in your code and then pass the file name to the cosole, like: %run my_file.py
Related
I have a python package installed on my machine. I could interface with it via the command line. How could I enter my debugger to see the "Call Stack" of the currently running processes that were executed by me from the terminal. Example, running "packagex command --argument" executes a process, I want to see what is happening with this call.
I'm not certain of what to try because the following searches didn't reveal what I am trying to do.
debug a command called from a terminal vscode
debugging an entire package vscode
debug client process vscode
...
It may be that I'm not searching for the correct thing which is why I'm not finding an answer.
Have installed angular CLI via node js command prompt. However, when I launch terminal in VS code, it doesn't allow to type only. PFA screenshot
PFB terminal setting screenshot
Able to run ng commands from node js command prompt outside vs code.
If your problem is not related to default shell in your terminal. Then you check windows settings. Follow the steps -
Open VSCode file location
Go to Compatibility tab in VSCode properties window
Unchecked Run this program in compatibility mode for: option
see the attached files. Try with this solution, it might help you.
This worked for me:
Remove settings file.
Click on view/terminal.
Select default shell.
I have several python projects loaded in one pycharm workspace. All but one I can step into normally. One project, however, when I set a breakpoint on, say, the first line of the boilerplate, pycharm says it's Collecting data... for about 10 to 20 seconds then says Unable to display frame variables.
Trying to step over or into the code freezes pycharm for another 20 seconds.
PyCharm still stops at breakpoints, I can see the stack and, with some patience, click on the frames.
I've checked the project configuration and everything seems the same as the other projects, or consistent from one project to another, including the Project, Environment variables, Python interpreter, Interpreter options (none), Script and Working directory.
I've tried running the project in a separate workspace with the same results.
I've reinstalled the debugger as suggested here
I've upgraded to 2016.3
I was using PyCharm 2016.2.3 with Python 2.7.12 :: Anaconda 4.1.1 (x86_64), now PyCharm 2016.3
What am I missing?
You should put the Pycharm Debugger in gevent compatible mode.
File > Settings > Build, Execution, Deployment > Python Debugger > Gevent compatible
The lines you removed probably had a purpose and you shouldn't delete them without knowing the consequences.
The code, which I didn't write myself, contained the following:
from gevent import monkey
monkey.patch_all()
Removing those lines resolved the issue.
In PyCharm, if I run a script in debug mode (with debug console on), then stop at a breakpoint, and try to type something into the console, I get:
MultipleInstanceError: Multiple incompatible subclass instances of PyDevTerminalInteractiveShell are being created.
Does anybody know what might be causing this and how to fix it?
For me, I had this issue when using ipdb in another terminal from the same code. I had ipdb present in file A, and a terminal with an ipython shell open running this code. I commented out the ipdb bits from file A and ran the debugger in pycharm and this error started up. When I closed the shell I had open in my terminal the error went away.
I am writing a Cocoa application with Mono embedded. I want to run and see my debug output in Terminal. On the Cocoa side I am using NSLog(), and on the Mono side I am using Debug.Write(). I can see my debug output in Xcode's console, but not in Terminal. This is what I tried:
$: open /path/build/Debug/MyProgram.app
$: open /path/build/Debug/MyProgram.app > output
$: open /path/build/Debug/MyProgram.app 2> output
in a terminal but I do not my output on the console or in 'ouput'.
What's the correct command?
PS. My ultimate goal is to write a vim plugin to manage, build, run, debug the xcode project. You can save me this hassle if you can get this vi input manager to work with xcode.
Chris gave a good overview of how the Console works, but to specifically answer your question: If you want to see the results directly in your Terminal, you need to run the built product as a child of the Terminal, which means using something like
/path/debug/build/MyProgram.app/Contents/MacOS/MyProgram
to launch the app.
Terminal on Mac OS X is just another application. Opening a terminal window for text I/O is not an inherent capability of every application as it is on Windows.
Furthermore, open /path/to/MyApp.app does not execute MyApp.app as a subprocess of your shell, it sends a message to the operating system's launch infrastructure asking it to execute the application in a normal fashion, the same as if it were double-clicked in the Finder or clicked in the Dock. That's why you're not able to just redirect its output to see what your app is sending to stdout or stderr.
You can use Console.app to see the output of applications launched in the normal manner, because the launch infrastructure specifically sends their stdout and stderr there. You can also use the asl routines to query the log, or perform more sophisticated logging if you so desire.
Open Console.app in /Applications/Utilities. All NSLog output will be printed in the System log.
Or, if you run it from within Xcode, all of the output will be printed in the Debug console.
I'm not on my Mac right now and don't recall the command sequence or the menu the Debug Console is in, possibly the Build menu?
Overview
The idea is to simply run the app from command line using ios-deploy.
Instructions
Install ios-deploy
Run the app from xcode (make sure it runs successfully)
go to xcode menu > preferences > locations and click on arrow in derived data:
in the derived data directory, search for your .app file under Build/intermediates/Products
in the terminal type the following
ios-deploy --debug --bundle
then drag the .app file from step 4 unto the terminal.. you should have something like this
ios-deploy --debug --bundle path/to/your/applicationName.app
and that's it! The app should successfully run and all the logs will go to your terminal.