What do I use on linux to make a python program executable

后端 未结 7 668
-上瘾入骨i
-上瘾入骨i 2020-11-27 15:55

I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.

7条回答
  •  忘掉有多难
    2020-11-27 16:05

    Putting these lines at the starting of the code will tell your operating systems to look up the binary program needed for the execution of the python script i.e it is the python interpreter.

    So it depends on your operating system where it keeps the python interpreter. As I have Ubuntu as operating system it keeps the python interpreter in /usr/bin/python so I have to write this line at the starting of my python script;

    #!/usr/bin/python
    

    After completing and saving your code

    1. Start your command terminal

    2. Make sure the script lies in your present working directory

    3. Type chmod +x script_name.py

    4. Now you can start the script by clicking the script. An alert box will appear; press "Run" or "Run in Terminal" in the alert box; or, at the terminal prompt, type ./script_name.py

提交回复
热议问题