How to make a Python script standalone executable to run without ANY dependency?
I'm building a Python application and don't want to force my clients to install Python and modules. I also want to make my application closed-source.
So, is there a way to compile Python scripts to standalone executables?
您可以使用py2exe作为已经回答并使用cython转换您的.pyc
文件中的密钥.py
文件,C编译文件,例如Windows中的.dll
和Linux中的.so
,比常用的.pyo
和.pyc
文件更难以恢复(和在性能上也有所收获!)
You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac.
PyInstaller Quickstart
Install PyInstaller from PyPI:
pip install pyinstaller
Go to your program's directory and run:
pyinstaller yourprogram.py
This will generate the bundle in a subdirectory called dist
.
For a more detailed walkthrough, see the manual.
You might wish to investigate Nuitka. It takes python source code and converts it in to C++ API calls. Then it compiles into an executable binary (ELF on Linux). It has been around for a few years now and supports a wide range of Python versions.
You will probably also get a performance improvement if you use it. Recommended.
链接地址: http://www.djcxy.com/p/6572.html上一篇: 是否有可能在Python中创建抽象类?