Use the Before Launch field of the Python run/debug configuration to define some scripts to be launched before running your application. PyCharm runs the specified script, and after success, it will run the application. Otherwise, the application starts immediately.

Learn more