How to reinitialize the Python console in PyCharm?
Question:
I’ve seen other IDEs have the option to right click and reinitialize the environment. Does anyone know if this is possible in PyCharm, and if so, how it’s done?
Answers:
There is a little reset button (small square with a curved green arrow can be seen above) on the top left of the console that says "Rerun" as the tool tip; this seems to reset the console.
If you can’t see the button, the Toolbar might be hidden. To get the Toolbar you need to right click on the "Python Console" tab, and click on "Show Toolbar"
The other answer is correct, I’m adding a new answer on how to create a shortcut for re-running the console. By default, it doesn’t have any shortcut, but you can add it by mapping it in Keymap.
-
Open Preferences (in Mac: Cmd+,
) and search for “rerun”
-
Add the keyboard shortcut for Rerun by double-clicking the “Rerun” line. As you can see from the image below, I assign Cmd+Shift+O
for it.
Now you can rerun the console by using the shortcut and don’t have to use your mouse anymore.
Please note that this button does not reset all the variables. But then you can enter in the command prompt: reset.
I had tried "rerun" and found that it didn’t reload the new environment.
I suggest that "new console" button could help you to reload the environment that it had installed the new packages.
I’ve seen other IDEs have the option to right click and reinitialize the environment. Does anyone know if this is possible in PyCharm, and if so, how it’s done?
There is a little reset button (small square with a curved green arrow can be seen above) on the top left of the console that says "Rerun" as the tool tip; this seems to reset the console.
If you can’t see the button, the Toolbar might be hidden. To get the Toolbar you need to right click on the "Python Console" tab, and click on "Show Toolbar"
The other answer is correct, I’m adding a new answer on how to create a shortcut for re-running the console. By default, it doesn’t have any shortcut, but you can add it by mapping it in Keymap.
-
Open Preferences (in Mac:
Cmd+,
) and search for “rerun” -
Add the keyboard shortcut for Rerun by double-clicking the “Rerun” line. As you can see from the image below, I assign
Cmd+Shift+O
for it.
Now you can rerun the console by using the shortcut and don’t have to use your mouse anymore.
Please note that this button does not reset all the variables. But then you can enter in the command prompt: reset.
I had tried "rerun" and found that it didn’t reload the new environment.
I suggest that "new console" button could help you to reload the environment that it had installed the new packages.