python / cpython

The Python programming language
https://www.python.org
Other
63.41k stars 30.36k forks source link

execution of file with pictures doesn't work in command --onefile in pyinstaller #84641

Closed 51dcc8b9-9736-4005-9b82-eb6e1546b85c closed 4 years ago

51dcc8b9-9736-4005-9b82-eb6e1546b85c commented 4 years ago
BPO 40461
Nosy @ned-deily
Files
  • Aplicacion_Calculadora.zip
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = created_at = labels = ['3.8', 'type-feature', 'library'] title = "execution of file with pictures doesn't work in command --onefile in pyinstaller" updated_at = user = 'https://bugs.python.org/HugoBenavides' ``` bugs.python.org fields: ```python activity = actor = 'ned.deily' assignee = 'none' closed = True closed_date = closer = 'ned.deily' components = ['Library (Lib)'] creation = creator = 'Hugo Benavides' dependencies = [] files = ['49103'] hgrepos = [] issue_num = 40461 keywords = [] message_count = 2.0 messages = ['367811', '367910'] nosy_count = 2.0 nosy_names = ['ned.deily', 'Hugo Benavides'] pr_nums = [] priority = 'normal' resolution = 'third party' stage = 'resolved' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue40461' versions = ['Python 3.8'] ```

    51dcc8b9-9736-4005-9b82-eb6e1546b85c commented 4 years ago

    hi, I have a problem to crete an executable using the command pyinstaller at the time of use the helper --onefile

    I've created an executable using the next instruction:

    pyinstaller --windowed --add-data "Rute PC to my Folder\Imagen";"Imagen" Aplicacion_Calculadora.py

    The folder Imagen has an imagen that is called into the code and at this time everything work fine, the executable starts and works very fine. I have used the calculator and operations are correct and the imagen is upload in the interface, but I deleted everything and started again.

    I would like to add everything in one File using the command:

    pyinstaller --onefile --add-data "Rute PC to mi Folder\Imagen";"Imagen" Aplicacion_Calculadora.py

    At this point, the executable never starts. If I saw the message in console when the .exe is running and it shows me the next error:

    File "tkinter\init.py", line 4061, in __init File "tkinter\init.py", line 4006, in __init _tkinter.TclError: couldn't open "./Imagen/Retroceder.png": no such file or directory [11320] Failed to execute script Aplicacion_Calculadora

    The executable never can find the folder and the imagen, it happenning just when I use the command --onefile

    I've been looking in every documentation and instructions but I've not found anything about that error just using the command --onefile

    May you help me with that error or what instruction I should add, please?

    Attach code and folder with the imagen

    Thanks

    ned-deily commented 4 years ago

    PyInstaller is a third-party project, not part of the Python Standard Library. I suggest you start with their documentation here:

    https://pyinstaller.readthedocs.io/en/stable/when-things-go-wrong.html