Sample python code for PyInstaller?
Here is a sample Python code for PyInstaller:
# hello.py
def hello():
print("Hello, World!")
if __name__ == '__main__':
hello()
To create an executable file using PyInstaller, follow these steps:
- Install PyInstaller using pip:
pip install pyinstaller
-
Navigate to the directory containing your Python script.
-
Run the following command to create a standalone executable file:
pyinstaller --onefile hello.py
This will create a single executable file named hello in the dist directory.
- Run the executable file by navigating to the
distdirectory and running:
./hello
This should output "Hello, World!" to the console.
原文地址: http://www.cveoy.top/t/topic/f3a 著作权归作者所有。请勿转载和采集!