Why is the green run button grey/disabled? Pycharm [duplicate] - python

I observed that on a new project the Run option is disabled and I expected to be able to run a script without having to manually add a configuration for it.

If you're creating a project from existing source:
and
If the existing source directory contains a lot of data/files:
the Run option (and others, assumably) are disabled until PyCharm is finished indexing the contents in the project. You'll see a progress bar in the lower-right-hand corner.
You can speed this up by right-clicking on folders and selecting "Mark directory as..." -> "Excluded" if they aren't to be indexed.

Right click inside your main file & then you get Run option!

You can't run without a configuration, however temporary configuration can be created automatically if you use Run context menu option in the script editor.

I solved it just by right clicking on the .py file and clicking 'run'. After this the run button appeared enabled!

If the project folder contains a lot of files then the indexing process can take a long time. So you might need to wait before the Run button appears.

Select drop down menu to the left of the run button at the top right, select Edit configurations, expand defaults on the left, select whatever you were working on (if python, select python). Then click OK. Dialogue will close. Make sure the file that you want to run is on top. Hit ctrl+shift+F10 to run. The run button should be enabled again.

Select your file name in drop down menu on top right corner.
Then go to edit configurations.
Next the Run/Debug Configurations dialog box will be open.
Then under execution, uncheck Run with Python console
Apply> Ok
Then you will get the Run window again.

It is possible that when you have newly setup your pycharm environment, it starts to index the scripts. You will see something like Indexing... at the bottom of the window. Once it is complete you can right click and select Run.

I tried all answers, and none worked for me. What did work is:
1.) open another repository / project
File > Open > select project > OK
2.) If you have the pop-up to choose "This Window or "New Window", chose "This Window"
3.) Open the repository / project that had the greyed out run button
4.) It should be green by now

Related

"Browse file" window freeze code execution in pywinauto

I am working on automating program that requires choosing file path.
After I click the browse button using code:
dlg.child_window(auto_id='btnBrwsBinFile').click()
browse window opens and freeze execution of code and I cannot control the popup window.
I have tried also different approach. I have edited text filed using code:
dlg['Edit'].set_text(path)
but then program do not see the path, it treats the field like it was never edited, like it was empty
I would like to ask if someone solved this issue before.
try:
dlg.child_window(title='btnBrwsBinFile').click_input()
pywinauto documentation:https://pywinauto.readthedocs.io/en/latest/code/pywinauto.findwindows.html
You can use UISpy.exe to get the title, class name

How to change PyCharm keyboard shortcuts on Mac

I want to change the run console command to pressing SHIFT and ENTER. I followed this tutorial but am unable to understand the actual step to input my personal commands.
I've made it all the way to the screenshot below and need more specific directions to input my personal commands. What do I do next?
That tutorial is about controlling/setting config for a specific run/script. To change keyboard shortcut/settings go your PyCharm preferences. Select Keymap on the left and in the search bar type "Run". You should see it under Run as the first option. Right click on it and you should see an "Add Keyboar Shortcut" and enter your preferred keyboard shortcut.
Keep in mind that Shift + Enter is already assigned so either change that or try another combination

Show run & debug toolbar in PyCharm

How do I get this run & debug toolbar to show in PyCharm? It shows in some of my projects, but not others.
And, in the spirit of teaching a man to fish, is there an easy way to find this using PyCharm's own help facility?
As #lukassz commented above, if you want to have the run/debug toolbar, you have to edit your run/debug configuration:
The manual way:
Go to Run > Edit Configuration > Hit the + sign on the top left of the subsequent window > Create a new run configuration.
The semi-automatic way:
With the file that you want to run, open on your editor, hit Shift + Alt + F10 (if you are using the default keymap) or Run > Run/Debug .
On the subsequent pop-up window, choose the file to run and PyCharm will (try to) run it for you.
In the process, a configuration will be generated, which persists.
The fishing lesson: Here is a pond with fish and the tools to catch the fish in question.
Happy fishing and good luck :D
I was able to show the 'Run Configurations' toolbar by selecting View / Appearance / Toolbar.
If you right-click on the Toolbar, you can access 'Customize Menus and Toolbars' for further customisation.
More information on customizing Pycharm toolbars

Why does powershell freeze for a bit when running my python scripts

Sometime I look back at my terminal when there is a python script running and the console output has frozen, then I right-click on the terminal and the console output (printing to screen) beings again.
Its a bit disconcerting because sometimes I think my script has broken.
Do others also experience this? Anybody know a fix?
Thanks in advance for any responses
If it's intermittent with all other factors being unchanged, it sounds like you've inadvertently selected some text in the PowerShell console and it's halted updating output so that you can do something with it.
Next time, be careful to look to see if you have something selected before clicking.
I agree with #alroc's suggestion; i.e. the cause could be accidentally clicking on the console.
A solution to prevent this is to right click on the powershell console window's title bar, select properties, uncheck Quick Edit Mode, then click OK. This disables some features (i.e. copy by select & enter, paste by right click), but means if you accidentally click on the screen it does no harm.
Another solution's to simply press escape (or right click in the script's window) if the script's taking a while - generally that'll do no harm (i.e. it won't terminate your script), but it will exit the edit session, allowing the script to resume if it had been paused due to edit mode.
To play with these, run the below script, then click on the screen whilst it's running (this script just outputs a bunch of numbers).
1..99999999
To terminate the script completely, press ctrl+c.

Eric4 Python IDE - autosave and quick script/project start, run

I've got 2 problems with Eric4 IDE.
Can't find an option in preferences to autosave my changed files before running script. It's very annoying that I have to save my file and then run script.
Second problem is running a script. I can't find any button to run a script/project instantly. 'Run Script' button always opens a setting window.
One way to get around this, as it seems there is no built in way is to bind a key to save the file (ctrl+s), then run the script (F2), and finally hit enter (to close the settings window and run the code).
This bothered me a lot too, and I know this is 2 years late but it might help some else who comes here looking for this very solution, like I did. Here are the actual answers, ERIC v4.4:
Press F4 instead of F2.
The first time you have to use F2 to 'Start' the script, so dismiss the settings window. After that you can use F4 'Restart' and it will run with the settings you chose initially.
The Autosave option is well hidden unfortunately:
Settings-->Preferences-->Debugger-->General-->!Scroll down to!-->Start Debugging-->Autosave changed scripts
And you were spot on - these two things do have a huge impact on productivity.

Categories