Python python file packaging exe file

First install PyInstaller, PyCharmenter the command in the terminal window:

 pip install PyInstaller

Insert image description here
After the installation is complete, enter the command:

 pyinstaller -F /Users/sunshiyu/Desktop/PYTHON/demo1.py

demo1.pyIt is a simple Pythonfile 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

Insert image description here
Insert image description here

After the execution is completed, a folder named will demo1.pybe generated in the same directory as , containing an executable file. Double-click the file to execute:distdemo1.exe

Insert image description here

Guess you like

Origin blog.csdn.net/SSY_1992/article/details/132258125