我想将python脚本更改为可执行文件。
编译正确进行,并且可执行文件在我的计算机上正常工作。
问题是当我将exe.win32-3.8目录导出到另一台计算机时,该可执行文件不起作用。执行窗口打开并立即关闭。 IE窗口不会打开。
这是我的setup.py:
from cx_Freeze import setup, Executable
# On appelle la fonction setup
setup(
name = "CampaignRecovery",
version = "0.1",
description = "Ce programme recupère les campagnes depuis Opoci",
executables = [Executable("CampaignRecovery.py")],
)
还有我的源代码:
from selenium import webdriver
from selenium.webdriver.ie.options import Options
ieOptions = Options()
ieOptions.ignore_protected_mode_settings = True
browser = webdriver.Ie(options=ieOptions)
你能帮我吗?
致谢
答案 0 :(得分:0)
这是我的设置。不能保证能在您的情况下工作,只是确保您已在目标计算机上安装了python以进行测试。并通过CMD运行它。通过CMD,您将能够找出问题所在
import cx_Freeze
import sys
import os
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
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')
print(os.environ['TCL_LIBRARY'],os.environ['TK_LIBRARY'])
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
syspath = r"C:\Python\DLLs"
buildOptions = dict(
packages=["tkinter","pandas","numpy"],
excludes=[],
include_files=[('tcl86t.dll', os.path.join('lib', 'tcl86t.dll')),('tk86t.dll', os.path.join('lib', 'tk86t.dll'))]
)
executables = [cx_Freeze.Executable("[YOUR APP].py", base=base, icon="hitek.ico")]
cx_Freeze.setup(
name = "YOUR APP",
options = dict(build_exe=buildOptions),
version = "0.02",
description = "YOUR APP",
executables = executables
)