[英]Import file cx_Freeze
我有一個問題,每次我使用python setup.py build
,它都不會導入所有文件,例如ws.ini, tcl.dll, tk.dll
等。而將這些文件刪除,我的app.exe無法正常工作。 我試圖復制並粘貼這些文件,並且該應用程序可以正常運行,但是我需要一種自動導入的方法。 謝謝。
import sys, os
from cx_Freeze import setup, Executable
os.environ['TCL_LIBRARY'] = r'C:\Users\matheus.sales.GTONIATO\AppData\Local\Programs\Python\Python35\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\matheus.sales.GTONIATO\AppData\Local\Programs\Python\Python35\tcl\tk8.6'
build_exe_options = {
"packages": ["os", "configparser", "glob", "xml.dom", "lxml"],
"includes": ["lxml.etree", "lxml._elementpath"],
"include_files": ["img/logo.png", "README.md", "ws.ini", "tcl86t.dll", "tk86t.dll"]
}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name="myapp",
version="1.0.0",
description = "Web Service My App",
options = {"build.exe": build_exe_options},
executables = [Executable("interface.py", base=base)]
)
確切的錯誤是什么? 剛剛花了很長時間嘗試使cx_freeze工作,我發現您需要環境變量的正斜杠,並且需要給include_files提供路徑。 這對我有用:
import sys
import os
from cx_Freeze import setup, Executable
os.environ['TCL_LIBRARY'] = 'C:/Program Files/Python36/tcl/tcl8.6'
os.environ['TK_LIBRARY'] = 'C:/Program Files/Python36/tcl/tk8.6'
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"includes": ["tkinter","unguilded"],
"packages":["tkinter"],
"include_files":["C:/Program Files/Python36/DLLs/tcl86t.dll", "C:/Program Files/Python36/DLLs/tk86t.dll"]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "Scraper",
version = "0.1",
description = "Scrapper",
options = {"build_exe": build_exe_options},
executables = [Executable("Scrape.py", base = base)])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.