Closed jaiwardhan closed 5 years ago
I'm afraid I'm not familiar enough with these tools to debug the issue. Perhaps you should try to report this issue on their side. I don't know of anything that the package is doing wrong so I don't have anything to fix.
For Pyinstaller use these additional commands: --hidden-import pkg_resources --hidden-import infi.systray
@activatedtmx You're very great!
In the past, I put the following code in my scrip (.py) from infi.systray import SysTrayIcon I already installed infi.systray from pip and checked the installed version with this command pip show infi.systray (Result: Version: 0.1.11); location: C:\Users\Admin\appdata\local\programs\python\python37-32\Lib\site-packages\ with 2 folders: "infi" and "infi.systray-0.1.11-py3.7.egg-info"). +My OS Windows 7 (32 bit) +Python 3.7.1
*Firstly, I run my program successfully on console: python my_program.py However, I built the .exe file by pyinstaller and ran the .exe file: +Sometimes, I double clicked on .exe and saw error "Failed to execute script" and the program stopped +Sometimes, I double clicked on .exe and with no error but nothing happened. (the program stopped)
*I checked carefully and realized that the error just happened at the line in my script: from infi.systray import SysTrayIcon And it just happened if file .exe (it's okay with running my_program.py from consonle with python)
*I followed your instruction and it's good to build file .exe and the file .exe works well. Here is my full command to build my program: _pyinstaller --hidden-import pkg_resources --hidden-import infi.systray --add-data="Becksport.jpg;." --add-data="becksport__eZD_icon.ico;." --icon="becksport__eZD_icon.ico" -d all myprogram.py
After running that command, I saw values automatically generated in my_program.spec as: hiddenimports=['pkg_resources', 'infi.systray']
To be noted that we need to copy 2 folders "infi" and "infi.systray-0.1.11-py3.7.egg-info" into the same folder containing file my_program.py and my_program.spec. It let pyinstall locate the installed packages. If I don't copy installed packages to the same folder containing file my_program.py and my_program.spec, maybe we need to modify the command line of pyinstaller to let it know where the installed packages are.
One more time, thank you so much for your instruction.
Solution by @activatedtmx seems to be the solution at least for Pyinstaller
. Closing it as per comments.
Issue: Packaging a simple systray project with cx_Freeze or PyInstaller breaks when building with the following error (last 3 traceback calls)
File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 342, in _GetModuleFinder finder.IncludePackage(name) File "C:\Python27\lib\site-packages\cx_Freeze\finder.py", line 659, in IncludePackage module = self._ImportModule(name, deferredImports) File "C:\Python27\lib\site-packages\cx_Freeze\finder.py", line 351, in _ImportModule raise ImportError("No module named %r" % name) ImportError: No module named 'infi.systray'
Steps to reproduce:
Make a simple project with infi.systray to show a tray icon (any simple sample project will do)
Try to package that with PyInstaller or cx_Freeze to try and get a binary
When running the command, the build breaks as it is unable to find the infi.systray package.
The naming seems to be the problem since it works well with all other pip libraries. Or maybe a namespace issue.