我完成了我的第一個完整的python程序,並試圖創建一個exe。我成功地構建了exe,但它運行並且什麼都不做。我猜測它沒有包含所有的軟件包。我可以用cx_Freeze中的build_exe_options指定這些,但我不知道程序包和不包括之間的區別。什麼是cx_Freeze和Python的各種build_exe_options?
這些都是我用的是進口在我的計劃
import os
import smtplib
from datetime import datetime, timedelta
from ftplib import FTP_TLS
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
下面是我的當前設置文件
from cx_Freeze import setup, Executable
setup(
name = "FTPConnect",
version = "1.0",
description = "Connects to FTP to download docs",
executables = [Executable("main.py")]
)
我猜我可以做這樣的事情,對不對?
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "smtplib", "datetime", "ftplib", "email.mime.text", "email.mime.multipart" ], "excludes": []}
setup(
name = "FTPConnect",
version = "1.0",
description = "Connects to FTP to download docs",
options = {"build_exe": build_exe_options},
executables = [Executable("main.py")]
)
我剛剛經歷了一個類似的難題(https://stackoverflow.com/questions/45734926/build-a-exe-for-windows-from-a-python-3-script-importing-pyqtgraph-and-開口)。你最終得到了一些改進? –