How to execute python file in linux

前端 未结 7 662
长情又很酷
长情又很酷 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:50

    If you have python 3 installed then add this line to the top of the file:

     #!/usr/bin/env python3
    

    You should also check the file have the right to be execute. chmod +x file.py

    For more details, follow the official forum:

    https://askubuntu.com/questions/761365/how-to-run-a-python-program-directly

提交回复
热议问题