在将软件安装到另一台使用python制成的计算机中时,如何解决绝对路径错误?

问题描述

我使用python tkinter制作了一个应用程序,并使用cx_Freeze创建了一个msi文件,但是当我尝试将其安装在其他计算机上时,却显示 cx_Freeze的 traceback错误:Python错误在主脚本中

enter image description here

实际上,该软件正在使用我自己计算机的启动文件路径,但是我想要实际用户计算机中的相对路径。那么,我该如何解决呢?在创建内置的msi或其他任何东西时我是否必须做一些事情。请帮帮我!

这是我的设置代码:-

from cx_Freeze import setup,Executable
import sys
import os 
base = None

if sys.platform == 'win32':
    base = "win32gui"
elif sys.platform == 'win64':
    base = "Win64GUI"

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,'tk8.6')


include_files=[(os.path.join(PYTHON_INSTALL_DIR,'DLLs','tk86t.dll'),os.path.join('lib','tk86.dll')),(os.path.join(PYTHON_INSTALL_DIR,'tcl86t.dll'),'tcl86.dll')),]

executables = [Executable("text_editor.py",base=base,icon=".\icon.ico",shortcutName='SOHAM TEXT EDITOR',shortcutDir='DesktopFolder')]


setup(
    name = "SOHAM TEXT EDITOR INSTALLER",options = {"build_exe": {"packages":["tkinter","os"],"include_files":include_files}},# options = {'build_exe':{'include_files'}},version = "0.01",description = "Hi I am Soham,I had made this Text Editor using Tkinter Application in Python,I had made this project for edit text,this is very compatable to user and easy to understand.",author = "SOHAM DAS BISWAS",executables = executables
    )

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)