Pycharm: MultipleInstanceError: Multiple incompatible subclass instances of PyDevTerminalInteractiveShell are being created - debugging

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.

Related

How to Debug python package command line arguments

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.

Msys terminal error in opening new terminal

Sometimes when i open the msys2 mingw64 bit terminal an error is displayed in console:
Error: Could not fork child process: There are no available terminals (-1).
This error oqurues many time during the project time, but if i restart the laptop, there is no error.
Anyone who has facing simillar error?
I have seen this issue too, and it disappears after reboot.
Make sure you have run autorebase.bat in the msys64 folder.

Spyder executing in terminal although I selected iPython

I'm on a Macbook. I have been using Spyder for a while with no trouble, but this morning when trying to run my scripts, it was not executing within the iPython screen, but rather in a separate terminal. Or rather it appears to start executing in the iPython screen but then the rest of it runs in a terminal window. I have no idea why this happened but I would very much like for all of my codes to run within the Spyder iPython window, not in the terminal.
what shows up in the iPython console when I hit run
run executes in the terminal window. I want all this to happen in the iPython window.
Any help?
Thanks,
Ty

How to debug code running from terminal in pycharm

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

How can I automatically run my programs in a Terminal window & debug with Xcode?

I am building a program on Mac OS that uses the curses library. When I attempt to run it inside Xcode, I get this error message:
Error opening terminal: unknown.
And then curses calls exit.
Obviously, it works from a Terminal window.
Is it possible to launch my program in a terminal window from Xcode? I know that I can use the "Wait for XXX to launch" option, but a lot of Xcode's helpfulness in starting programs vanishes that way, so I would be looking for another way.
Xcode uses GDB, or LLDB for debugging.
You can invoke them directly from a terminal. This way, your executable will be attached to a working one.
Try:
gdb path/to/my/executable
Then, from the GDB prompt, type:
run
To start your program in debugging mode.
Take a look at the GDB manual for learning stuff like debugging commands, breakpoints, etc.

Resources