How to build a single python file from multiple scripts?

前端 未结 8 1753
终归单人心
终归单人心 2020-12-24 01:30

I have a simple python script, which imports various other modules I\'ve written (and so on). Due to my environment, my PYTHONPATH is quite long. I\'m also using Python 2.

8条回答
  •  自闭症患者
    2020-12-24 02:09

    You can try converting the script into an executable file. First, use:

    pip install pyinstaller

    After installation type ( Be sure you are in your file of interest directory):

    pyinstaller --onefile --windowed filename.py

    This will create an executable version of your script containing all the necessary modules. You can then transfer (copy and paste) this executable to the PC or machine you want to run your script.

    I hope this helps.

提交回复
热议问题