How can I run the current file in PyCharm

How can I run the current file in PyCharm? I would like a single hotkey that will execute the current file (whether normal file, scratch file, or scratch buffer) using the project default python interpreter. I would like to NOT have to create a custom run configuration, but just launch with the default Python configuration. Is such a thing possible?


Solution 1:

As it turns out, the action I was seeking is "Run context configuration" (or "Debug context configuration" for debugging). The default key binding on Windows is ctrl+shift+f10, or ctrl+option+R on Mac, as Ev. Kounis pointed out, although you can bind it to any key you like.

These settings can be found under the "Other" section in File->Settings->Keymap. The easiest way to find them is to simply use the search box.

Solution 2:

Just right click on the tab of your file and click run "file name" or you can press CTRL+shift+F10

Screenshot

Solution 3:

The key combination you are looking for is Ctrl + Shift + F10. This will run the current script with current being the one displayed in the viewer.

Solution 4:

There are several alternatives:

  1. Run context configuration from editor shortcut:

Mac: R

Windows/Linux: Ctrl + Shift + F10

  1. You can right click on the file, and then run Run 'filename'.

enter image description here

  1. You can also run the shortcut to Find Action and then type run:

Mac: A

Windows/Linux: Ctrl + Shift + A

enter image description here

  1. If the current file was just run, you can simply use the Run shortcut:

Mac: R

Windows/Linux: Shift + F10


References:

PyCharm Shorcuts for Mac OS X

PyCharm Shorcuts for Windows and Linux