Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run ipdb with seperate terminal in pycharm

Information

I faced an annoying thing with PyCharm in the last couple of days. I'm trying to use ipdb to debug my program instead of pycharm debugger but I can only open it in thepycharm i/o console or in the python console.

Question

Is there anyway that I can open the debugging session in the terminal window? or even in a new terminal window? I alos want to be able to open the session from the debugging button, and don't write any line like python src/main.py by my self in the terminal

The main reason I want to do it so I can have an auto complete as I get from ipython in the terminal, but I couldn't find a way to open the debugging session in terminal window, is there anyway to do it? and plugin that can help? the autocomplete that the python console gives me is very weak and not really helping me

System information

Pycharm 2018.3

Centos 7 64bit

like image 706
Reznik Avatar asked Nov 08 '19 13:11

Reznik


People also ask

How do I run a python script in PyCharm with parameters?

Passing Command-line arguments in PyCharm If you want to pass command-line arguments to a python program, go to “Run > Edit Configurations” and set the Parameters value and save it.

How do I run a command from PyCharm terminal?

Press Alt+F12 to open terminal within PyCharm, then write in the command you wish to run and press enter. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research!

How do I run separate independent Python scripts in PyCharm?

In a given PyCharm project, I want to run separate independent Python scripts under separate 'run' tab. How do I do that in PyCharm ? As easy as it sounds. Just run your Python scripts and PyCharm will create a separate tab for each in Run tool window.

How do I split a session in PyCharm terminal?

Click on the toolbar to start a new session in a separate tab. To run multiple sessions inside a tab, right-click the tab and select Split Vertically or Split Horizontally in the context menu. The Terminal saves tabs and sessions when you close the project or PyCharm.

How do I change the line separator style in PyCharm?

With PyCharm, you can set up line separators (line endings) for newly created files, and change line separator style for existing files. Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style.


1 Answers

Updated

Here is a simple workaround that you can fork an open-source project from git and add a patch for persistent history. To install IPDB you can use the following command to fork the latest version:

pip install git+https://github.com/gotcha/ipdb.git

To install git projects using pip, visit pip install from git repo branch. Just make sure that your IPython version is 6.0 or higher.

Implementation Info: can be found in these Articles. Visit references: Use of IPDB and IPDB Persistent History .

Otherwise, you can also use pudb instead. It enables getting to a real ipython shell from the debugger and all the commands there are saved.


To launch Debugging Session, go to Pycharm Windows-Tool-Bar at the bottom and right click on terminal as follows:

To Open Terminal in Window Mode:

To Open Terminal in Window Mode:

When terminal is open in window mode, then you can open multiple debugging sessions as given below:

  • [ + ] to open multiple Sessions:*

 **+** to open multiple Terminals:

At the end you can use the following command to launch debugging sessions using this command:

$ python -m ipdb /path/my_test.py

This will initiate your debugging session using IPDB in PyCharm terminal window.

Here is a test result: Pycharm Debugging Session using IPDB:

like image 178
Muhammad Usman Bashir Avatar answered Oct 16 '22 14:10

Muhammad Usman Bashir