I have just started using PyCharm because I want to get more into Python (have more experience with other languages), and have run into a conundrum that there has to be a solution for. Some custom function I created relies on a module being imported in a particularly verbose way, so I don't want to have to copy-paste the same two lines every time I want to code, as opposed to simply typing import numpy as np.
So is there a way to automatically run some code on my environment's start? Particularly to import some modules? I looked around PyCharm's settings, and have found nothing.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With