简体   繁体   English

我无法在其他桌面上打开我的 EXE 文件

[英]I cannot open my EXE File on other Desktop

I finished my code on Pycharm. Now I want to convert my.py file into.exe After i converted it.我在 Pycharm 完成了我的代码。现在我想将我的.py 文件转换成.exe 转换后。 The application file are running on the desktop (desktop1) that I used to convert, but when i try to open the application on other desktop (desktop2) it has an error that says.应用程序文件在我用来转换的桌面 (desktop1) 上运行,但是当我尝试在其他桌面 (desktop2) 上打开该应用程序时,出现错误提示。

`Traceback (most recent call last):
  File "main.py", line 220, in <module>
    obj = DocumentsManagementSystem(root)
  File "main.py", line 20, in __init__
    self.root.iconbitmap(r'C://Users//HP//PycharmProjects//pythonProject1//Images//senglogo.ico')
  File "tkinter\__init__.py", line 2109, in wm_iconbitmap
_tkinter.TclError: bitmap "C://Users//HP//PycharmProjects//python`

but when i open it on the desktop (desktop1) it is running.但是当我在桌面 (desktop1) 上打开它时,它正在运行。 That's the issue.这就是问题所在。 I cannot open it on other desktop.我无法在其他桌面上打开它。 If you have any idea on how i can solve this.如果您对我如何解决这个问题有任何想法。 I will gladly do it.我会很乐意这样做。 Thank you so much!太感谢了!

Use pyinstaller with additional file and add-data parameters.使用带有附加文件和添加数据参数的 pyinstaller。 In your case use this command:在您的情况下使用此命令:

 pyinstaller --add-data  '//Users//HP//PycharmProjects//pythonProject1//Images//senglogo.ico:.' script.py

It seems like you missed adding an additional and data file in your pyinstaller process.您似乎错过了在 pyinstaller 进程中添加附加文件和数据文件。

if you're beginner you can use the GUI of pytinstaller.如果你是初学者,你可以使用 pytinstaller 的 GUI。 https://pypi.org/project/auto-py-to-exe/ https://pypi.org/project/auto-py-to-exe/

The required steps for py to exe. py 到 exe 所需的步骤。

  1. Analysis: Finding the Files Your Program Needs https://pyinstaller.org/en/stable/operating-mode.html#analysis-finding-the-files-your-program-needs分析:查找程序所需的文件https://pyinstaller.org/en/stable/operating-mode.html#analysis-finding-the-files-your-program-needs

  2. Add required file by using this command:使用此命令添加所需文件:

     pyinstaller --add-data 'src/README.txt:.' myscript.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM