How can I run the current file in PyCharm
Question:
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?
Answers:
Alt+Shift+F10 and then select the script you want to run.
After that Shift+F10 will run the last script that has been run.
Keyboard shortcuts can be different on some machines. So you can just click right key on mouse and then “Run “(also you can select part of code and do the same)
File->Settings->Keymap->Run->Run
and see your current keymap
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.
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.
Basically, if you just need to run the current .py
file in PyCharm. Right-click inside the file, and you can click the “Run file.py” button, and it also tells you the shortcut which on Mac is Control + Shift + R.
There are several alternatives:
- Run context configuration from editor shortcut:
Mac: ⌃⇧R
Windows/Linux: Ctrl + Shift + F10
- You can right click on the file, and then run
Run 'filename'
.
- You can also run the shortcut to
Find Action
and then type run:
Mac: ⇧⌘A
Windows/Linux: Ctrl + Shift + A
- If the current file was just run, you can simply use the Run shortcut:
Mac: ⌃R
Windows/Linux: Shift + F10
References:
To Run/Execute current python file in Pycharm use following keys in windows machine
Shift+Ctrl+F10
OR
for selected code (specific line that are selected/marked)
Shift+Alt+E
When intalling on Pycharm select :
Add launchers dir to the PATH: Allows running this PyCharm instance from the Console without specifying the path to it.
🙂
Running file with Ctrl+Shift+F10 or via Run menu has some disadvantages. For example, you cannot use the custom redirect input file.
I have created a project it is that will actually allow you to use currently opened py file when you press run / debug in a standard way. My project will remain actual at least until jetbrains fix non working macros in configurations. See bug report.
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?
Alt+Shift+F10 and then select the script you want to run.
After that Shift+F10 will run the last script that has been run.
Keyboard shortcuts can be different on some machines. So you can just click right key on mouse and then “Run “(also you can select part of code and do the same)
File->Settings->Keymap->Run->Run
and see your current keymap
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.
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.
Basically, if you just need to run the current .py
file in PyCharm. Right-click inside the file, and you can click the “Run file.py” button, and it also tells you the shortcut which on Mac is Control + Shift + R.
There are several alternatives:
- Run context configuration from editor shortcut:
Mac: ⌃⇧R
Windows/Linux: Ctrl + Shift + F10
- You can right click on the file, and then run
Run 'filename'
.
- You can also run the shortcut to
Find Action
and then type run:
Mac: ⇧⌘A
Windows/Linux: Ctrl + Shift + A
- If the current file was just run, you can simply use the Run shortcut:
Mac: ⌃R
Windows/Linux: Shift + F10
References:
To Run/Execute current python file in Pycharm use following keys in windows machine
Shift+Ctrl+F10
OR
for selected code (specific line that are selected/marked)
Shift+Alt+E
When intalling on Pycharm select :
Add launchers dir to the PATH: Allows running this PyCharm instance from the Console without specifying the path to it.
🙂
Running file with Ctrl+Shift+F10 or via Run menu has some disadvantages. For example, you cannot use the custom redirect input file.
I have created a project it is that will actually allow you to use currently opened py file when you press run / debug in a standard way. My project will remain actual at least until jetbrains fix non working macros in configurations. See bug report.