cx_Freeze - 从桌面快捷方式运行 .exe 时出错 [英] cx_Freeze - Error when running .exe from desktop shortcut

查看:27
本文介绍了cx_Freeze - 从桌面快捷方式运行 .exe 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 cx_Freeze 中编译为 msi 后,我的 Pygame 应用程序从 .exe 文件完美运行,但是当我从桌面快捷方式运行它时,出现错误:

My Pygame app runs perfectly from the .exe file after being compiled as an msi in cx_Freeze, but when I run it from the desktop shortcut, I get an error:

快捷方式Target是正确的,声音文件都在正确的目录中,我已经尝试了.wav.ogg文件并降低了比特率等,但是似乎没有任何效果.令人沮丧的是,当我打开目标位置并手动运行 .exe 时,它运行完美.我不明白为什么桌面快捷方式会导致错误.

The shortcut Target is correct, the sound files are all in the right directory, I have tried both .wav and .ogg files and reduced the bitrate etc, but nothing seems to work. The frustrating thing is, it runs perfectly when I open the target location and run the .exe manually. I cannot figure out why the desktop shortcut method is causing an error.

这是我的 setup.py 文件:

import sys
import cx_Freeze

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

executables = [cx_Freeze.Executable(
    script="a_bit_racey.py",
    base=base,
    icon="car_icon.ico",
    shortcutName="A bit Racey",
    shortcutDir="DesktopFolder")]

cx_Freeze.setup(
    name="A bit Racey",
    options={"build_exe": {"packages": ["pygame"],
                           "include_files": ["racecar.png", "Crash.ogg", "Ecstasy_X.ogg",
                                             "car_icon.ico"]}},
    executables=executables
)

我是否缺少快捷方式所需的 msi 属性?我已经坚持了一个星期.

Am I missing an msi property that the shortcut needs? I've been stuck on this for a week.

这是一个可能更好解释的屏幕截图,因为我得到的回应很少:

Here is a screenshot that might better explain, as I'm getting very little response:

用 cx_Freeze 创建的桌面快捷方式有正确的目标位置,甚至似乎运行 .exe 文件,但随后出错.然而,当我打开目标位置并双击 .exe 文件时,它运行得很好!!

The desktop shortcut that was created with cx_Freeze has the correct target location, and even seems to run the .exe file, but then errors. Yet, when I open the target location and double-click the .exe file, it works perfectly!!

推荐答案

cx-freeze.readthedocs.io/en/latest/faq.html#data-files

cx-freeze.readthedocs.io/en/latest/faq.html#data-files

请确保在幕后使用绝对路径,就像这个 cx_Freeze 文档似乎让我相信.显然,在include_files"列表中,这些是相对的.你有 data_dir 查找功能吗?如果没有查看使用数据文件"部分的文档.

Please ensure that absolute paths are being used under the hood, like this cx_Freeze doc seems to lead me to believe. Obviously in the "include_files" list these are relative. Do you have a data_dir finding function? If not look in the docs for the "Using data files" section.

这篇关于cx_Freeze - 从桌面快捷方式运行 .exe 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆