I think absolute paths should include the drive letter as well e.g. "C:\\Users...."
I'm not sure why it can't open the file. One thing that comes to mind is that data files will be put in the second part of the tuple "." in your case. So if your code is trying to open it from somewhere else instead of the current folder it might not be able to open it. This is purely guesswork though as I haven't used data files myself. On Wednesday, 9 March 2022 at 01:25:05 UTC+8 [email protected] wrote: > For clarification, the name of the icon though out my sample code snippet > outlining my problem should be given as "my_icon.ico" > The name "eeg_2022_win" is for my actual larger application. Apologies for > the confusion. > > On Tuesday, March 8, 2022 at 11:48:25 AM UTC-5 Paul Fishback wrote: > >> Edward LOWE , >> >> Thanks for the responses and suggestions. >> >> I'm still having difficulties. Here's what I tried: >> >> 1. I included the icon location to the EXE as you suggested by adding the >> argument >> icon='\\Users\\MyName\\Desktop\\my_icon.ico', >> >> 2. Based upon the Stack Overflow post you passed along, I included the >> icon in my data via >> datas=[('\\Users\\MyName\\Desktop\\eeg_2022_win.ico', '.')] >> >> 3. I deleted the icon reference in BUNDLE. >> >> This led to the error >> >> *Unable to find "\\Users\\MyName\\Desktop\\eeg_2022_win.ico" when adding >> binary and data files.* >> >> My .spec file and .ico are located in the same directory. It's not clear >> to me whether I should be using absolute or relative file paths, so I >> changed >> datas above to >> datas=[('eeg_2022_win.ico', '.')] >> >> This led to a new error message >> >> *Unable to open icon file \Users\MyName\Desktop\eeg_2022_win.ico* >> >> I also tried including the icon option in BUNDLE, using both absolute and >> relative file paths. This led again to the second error message immediately >> above >> >> I haven't worked with .ico file types before. To create my icon, I simply >> went to an online png-to-ico convertor. Are there particular criteria the >> ico must satisfy in order for pyinstaller to open it and associate it with >> my .exe ? >> >> Thanks. >> >> >> On Tuesday, March 8, 2022 at 5:58:15 AM UTC-5 [email protected] wrote: >> >>> >>> https://stackoverflow.com/questions/9946760/add-image-to-spec-file-in-pyinstaller >>> On Tuesday, 8 March 2022 at 17:00:51 UTC+8 [email protected] wrote: >>> >>>> I see this issue discussed elsewhere, but various suggestions haven't >>>> helped me. >>>> >>>> I have a working script that I've successfully converted to a windows >>>> .exe. >>>> >>>> Because I'll eventually need to add many hidden imports and data files, >>>> I'm using a spec file, which is as follows. However, for simplicity, I'll >>>> provide a stripped down version with nothing added: >>>> >>>> block_cipher = None >>>> a = Analysis(['my_script.py'], >>>> pathex=[], >>>> binaries=[], >>>> datas=[], >>>> hiddenimports=[], >>>> hookspath=[], >>>> hooksconfig={}, >>>> runtime_hooks=[], >>>> excludes=[], >>>> win_no_prefer_redirects=False, >>>> win_private_assemblies=False, >>>> cipher=block_cipher, >>>> noarchive=False) >>>> pyz = PYZ(a.pure, a.zipped_data, >>>> cipher=block_cipher) >>>> >>>> exe = EXE(pyz, >>>> a.scripts, >>>> a.binaries, >>>> a.zipfiles, >>>> a.datas, >>>> [], >>>> name='my_script', >>>> debug=False, >>>> bootloader_ignore_signals=False, >>>> strip=False, >>>> upx=True, >>>> upx_exclude=[], >>>> runtime_tmpdir=None, >>>> console=False, >>>> disable_windowed_traceback=False, >>>> target_arch=None, >>>> codesign_identity=None, >>>> entitlements_file=None ) >>>> >>>> app = BUNDLE(name='my_script.exe',icon= >>>> C:\Users\MyName\Desktop\my_icon.ico',bundle_identifier=None, >>>> info_plist={ >>>> 'LSEnvironment': { >>>> 'LANG': 'de_DE.UTF-8', >>>> 'LC_CTYPE': 'de_DE.UTF-8' >>>> }}) >>>> >>>> For some reason, I'm only getting the pyinstaller default icon. >>>> >>>> Suggestions? >>>> >>> -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/e9c86063-61eb-43f8-8659-0588b0c969ddn%40googlegroups.com.
