我无法 运行 cx_Freeze 构建的电子邮件程序

I can't run an email program built by cx_Freeze

我有一个程序可以像 Python 程序一样完美运行。然而,我尝试构建它 cx_Freeze ,当我开始发送电子邮件的程序部分时,我收到错误消息。 No SSL support included in this Python.

我的 setup.py 以及所有其他与电子邮件相关的模块中都有 smtplib。

import sys
from cx_Freeze import setup, Executable

import os
PYTHON_INSTALL_DIR = os.path.dirname(sys.executable)
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

packages = ["smtplib"]
include_files = [(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'), os.path.join('lib', 'tk86t.dll')),
                 (os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'), os.path.join('lib', 'tcl86t.dll')),
                ".env", "message.txt"]

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

executables = [
    Executable('boxes.py', base=base, targetName = "SuperbowlBoxesGenerator.exe", icon="icon.ico", copyright="MIT", trademarks="CompuGenius Programs")
]

setup(name='Superbowl Boxes Generator',
      version = '2.0',
      description = 'An automated generator for the betting game Superbowl Boxes.',
      author = "CompuGenius Programs",
      options={'build_exe': {'include_files': include_files, 'packages': packages}},
      executables=executables)

这是我的 setup.py 脚本。

有人请帮助我。这个程序是为我爸爸的生日准备的,由于我电脑上的文件被删除了,我不得不重写所有内容,所以已经过期了。

您需要将 ssl 添加到包中,并且

os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'libcrypto-1_1-x64.dll'),
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'libssl-1_1-x64.dll'),

到include_files。这是你修改后的 setup.py.

import sys
from cx_Freeze import setup, Executable

import os
PYTHON_INSTALL_DIR = os.path.dirname(sys.executable)
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

packages = ["smtplib", "ssl"]
include_files = [(os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'), os.path.join('lib', 'tk86t.dll')),
                 (os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'), os.path.join('lib', 'tcl86t.dll')),
                 os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'libcrypto-1_1-x64.dll'),
                 os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'libssl-1_1-x64.dll'),
                ".env", "message.txt"]

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

executables = [
    Executable('boxes.py', base=base, targetName = "SuperbowlBoxesGenerator.exe", icon="icon.ico", copyright="MIT", trademarks="CompuGenius Programs")
]

setup(name='Superbowl Boxes Generator',
      version = '2.0',
      description = 'An automated generator for the betting game Superbowl Boxes.',
      author = "CompuGenius Programs",
      author_email = "compugeniusprograms@gmail.com",
      options={'build_exe': {'include_files': include_files, 'packages': packages}},
      executables=executables)