简体   繁体   中英

How to execute python script using python command

When I execute a python script in the Pycharm IDE, It executes the script with the path to the python executable like so: path/to/python/executable path/to/the/script/foo.py

Is there a way to execute it with the python command like: python3 path/to/the/script/foo.py ?

I know that it makes no difference, and I know that I can just type in the command in the Terminal but I want it to be executed by pressing Ctrl+Shift+F10 (the shortcut key for executing the script) or by pressing the "run" button.

Yep, with your project opened, click edit configurations as image 1 shows. Edit configuration

Image 1:

In the opened window you can change Run configurations

Why do you want to run it specifically like that? If you wish to use some system interpreter, then you can just configure it in PyCharm and use to run all of your scripts or only specific ones. So in case you want to use Interpreter A as your project interpreter and Interpreter B to run some script, then just configure that Interpreter B in PyCharm and set it in Run/Debug configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM