How to execute python file in linux

前端 未结 7 654
长情又很酷
长情又很酷 2020-12-08 14:27

I am using linux mint, and to run a python file I have to type in the terminal: python [file path], so is there way to make the file executable, and make it run

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 14:47

    Add this at the top of your file:

    #!/usr/bin/python
    

    This is a shebang. You can read more about it on Wikipedia.

    After that, you must make the file executable via

    chmod +x your_script.py
    

提交回复
热议问题