First install PyInstaller
, PyCharm
enter the command in the terminal window:
pip install PyInstaller
After the installation is complete, enter the command:
pyinstaller -F /Users/sunshiyu/Desktop/PYTHON/demo1.py
demo1.py
It is a simple Python
file I created, the code is as follows:
import sys
import ssl
# 3.9.6 (default, Jul 18 2022, 15:31:42)
# [Clang 14.0.0 (clang-1400.0.29.100)]
print(sys.version)
# LibreSSL 2.8.3
print(ssl.OPENSSL_VERSION)
while True:
name = str(input("请输入姓名:"))
print(f"姓名:{
name}")
try:
age = int(input("请输入年龄:"))
print(f"年龄:{
age}")
except Exception as e:
print(e)
job = str(input("请输入职业:"))
print(f"职业:{
job}")
if name and age > 0 and job:
print("输入已完成!!!")
break
else:
print("输入有误,请重新输入!")
Replace this with the path to your own file
After the execution is completed, a folder named will demo1.py
be generated in the same directory as , containing an executable file. Double-click the file to execute:dist
demo1.exe