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

标签 python python-3.x ssl cx-freeze smtplib

我有一个程序可以像 Python 程序一样完美运行。但是,我尝试将其构建为 cx_Freeze,当我开始发送电子邮件的程序部分时出现错误。 此 Python 中不包含 SSL 支持

我的 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'),

包含文件。这是您修改后的 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)

关于python - 我无法运行由 cx_Freeze 构建的电子邮件程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57087219/

相关文章:

ssl - Amazon AWS 无法验证解冻证书链

google-app-engine - 非默认版本的 appspot.com 子域上的 SSL

android - 在 Android 设备中为 SSO 安装 SSL 证书

python - 如何测试设置和检查依赖于未经测试的方法的方法?

python - python 中合并排序的索引超出范围

python - python range()[ :] 的切片行为

python - 按短数字拆分列表

python - 将值四舍五入为最接近的可被 2、4、8 和 16 整除的数字?

python - 如何返回在 contains 中导致 True 标志的关键字

python - 无法计算列 python 的最小值/最大值/总和