微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在将软件安装到另一台使用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 举报,一经查实,本站将立刻删除。