Turn an application or script into a shell command

后端 未结 6 1924
走了就别回头了
走了就别回头了 2021-02-06 11:11

When I want to run my python applications from commandline (under ubuntu) I have to be in the directory where is the source code app.py and run the application with command
<

6条回答
  •  半阙折子戏
    2021-02-06 11:36

    Probably you want to symlink to your file location instead of adding another location to the path

    chmod +x app.py
    ln ~app.py /opt/local/bin/app
    

    ...assuming that /opt/local/bin is already in your path,.

    Also, do not forget to add the shebang line to the first line of your script: #!/usr/bin/env python

提交回复
热议问题