簡體   English   中英

Python cx_freeze安裝腳本不起作用

[英]Python cx_freeze setup script not working

我有一個要凍結的python腳本。 我制作了cx_freeze腳本並運行了它。 .exe可以正常工作,但是在凍結的腳本中,我打開了一個.html文件。 當文件打開時,網絡瀏覽器給我錯誤消息“ File not found: Firefox cannot find the file at /c:/blah/blah/blah/somefile.html

據我了解,這是因為cx_freeze在Linux和Windows之間混淆了我的操作系統。 但是,我不確定是不是因為我有代碼

if sys.platform == "win32":
   base = "Win32GUI"

在我的安裝文件中。 有人知道發生了什么嗎?

我的整個安裝文件是

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}

# 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 = "someexe",
    version = "0.1",
    description = "someexe description",
    options = {"build_exe": build_exe_options},
    executables = [Executable("someexe.py", base=base)])

cx_freeze distutils頁面復制並進行編輯以滿足我的需要。

您應該使用os.chdir('C:\\path\\to\\dir')而不是使用os.chdir('C:/path/to/dir') os.chdir('C:\\path\\to\\dir') 這是腳本中的錯誤,而不是cx_freeze安裝文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM