Run a Python script without the IDE

后端 未结 2 1704
余生分开走
余生分开走 2021-01-07 14:47

I have a python script I wrote which uses tkinter and panda to: choose a CSV file on the desktop, imports in that data, does some stuff, exports the new dataframe created i

相关标签:
2条回答
  • 2021-01-07 15:26

    Thanks to @abarnert, the solution was to use Pyinstaller which allows me to "freeze" the code into an exe file

    0 讨论(0)
  • 2021-01-07 15:44

    You can write a small executable script based upon your OS

    Windows

    Create a .bat file in which you need there needs to the command to execute your python file.

    e.g. c:\python27\python.exe c:\somescript.py %*

    For reference look here

    MacOS / Linux

    Create a .sh file which can be executed from your shell/terminal or by double clicking its sym link.
    Your .sh file will look like

    #!/bin/bash
    
    python PATH_TO_YOUR_PYTHON_FILE
    

    Then you must make it executable via running the following in terminal

    chmod u+x PATH_TO_.SH_FILE
    

    Alternatively you can create a symbolic link to your python file and make it executable. This symlink will be executable by double click. To create a symlink:

    ln -sf PATH_TO_.SH_FILE PATH_OF_SYMLINK
    

    If you put just a name in place of PATH_OF_SYMLINK it will be created in your present directory.

    0 讨论(0)
提交回复
热议问题