'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. 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.

`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. 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!



Solution 1:[1]

Use pyinstaller with additional file and add-data parameters. 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.

if you're beginner you can use the GUI of pytinstaller. https://pypi.org/project/auto-py-to-exe/

The required steps for py to exe.

  1. 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
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aadi