astroplot
astroplot

Reputation: 29

Auto run python scripts on pycharm while opening

I want to auto run the python script when I open it from the terminal so that I won't have to press the run button From the terminal I want to open the file as : pycharm-community main.py

How do I auto run it while it opens?

Upvotes: 2

Views: 1973

Answers (2)

Kim Miller
Kim Miller

Reputation: 886

Preferences > Tools > Startup Tasks, <+ Add> and select your main.py

Then anytime you open the project the script will run and display results.

I wanted main.py to run daily at a certain time, so used Keyboard Maestro. Keyboard Maestro is also able to control the running of main.py, eliminating the step above. That way my script runs only at the desired time of day, not every time I open the project.

Upvotes: 0

Ali Ahmad
Ali Ahmad

Reputation: 89

Do File | Settings | Tools | Startup Tasks (or Ctrl-Alt-S).

Then: Build, Execution, Deployment > Console > Python Console

This gives you a dialogue with an edit box Starting script. Put your import code there. That will run every time you open a new console.

Upvotes: 2

Related Questions