How can I run the current file in PyCharm

2019-02-03 01:39发布

问题:

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?

回答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, 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.



回答2:

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



回答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.



回答4:

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)



回答5:

File->Settings->Keymap->Run->Run and see your current keymap



回答6:

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.



回答7:

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.