fbs icon indicating copy to clipboard operation
fbs copied to clipboard

fbs freeze fails due to modules not found in PYZ

Open sydobrew opened this issue 6 years ago • 14 comments

Hello I want to thank you for development of fbs. I am hoping you can point me in the right direction for an issue I am having using it to package my second project. I've tried to compile the exe using python3.5 and python3.6 and the main script will fail each time even though fbs runs with no issue. The only errors I can find state module not found in PYZ this is happening for a wide range of modules. Using the same environment I can compile an empty startproject with no problem. I realize that this is likely a problem with my code organization but I don't understand what not found in PYZ is pointing me towards in order to find a fix. Any help would be greatly appreciated.

sydobrew avatar Sep 09 '19 06:09 sydobrew

I think I've also already seen these PYZ errors you mention, and don't think they will help much.

You say "the main script fails". What exactly do you mean by that? How does it fail? Do you simply not see anything? Do you get a dialog? ...? I cannot help you if you don't provide such information.

mherrmann avatar Sep 09 '19 07:09 mherrmann

Thank you for the quick response. The only information I get from the debug dialog when trying to run the application is the mentioned list of PYZ errors. No errors in the build dialog. I think it maybe related to some external resources that I am importing. I'm going to work with that and see if anything comes of it.

sydobrew avatar Sep 09 '19 14:09 sydobrew

Then I was too harsh, sorry. I would hope that there's is at least some interesting information in between all the PYZ errors. Are you sure there isn't some message or stack trace in there somewhere? What if you add print(...) statements to early parts of your code?

mherrmann avatar Sep 09 '19 15:09 mherrmann

I can't find anything consistent in the stack trace except for lots of missing files. After lots of tries using different environments I was able to build my project on a WIN7 machine with Anaconda Environments. However for whatever reason WIN10 seems to have lots of missing dll files and base python modules. Even after a fresh install of vanilla python on a clean WIN10 image many dll files are missing even if i manually copy the dll files to the locations they are ignored. even using a simple os.listdir in python refuses to acknowledge the files exist when they are clearly visible in a file viewer. I would say this is something I have done but the same problem arose on a machine that was working just fine for builds and a brand new image. I have a suspcision that it is related to the recent windows10 updates that seem to be wrecking havoc but I'm not really a windows user so I can't be sure.

sydobrew avatar Sep 11 '19 02:09 sydobrew

Well It seems that even after building and running fine on windows 7 I am having the same failure running the built application on windows 10. Could you confirm current builds from windows 10 are functional? Any information would be helpful.

sydobrew avatar Sep 17 '19 17:09 sydobrew

fman uses fbs, is built on Windows 7 and runs fine on Windows 10.

mherrmann avatar Sep 17 '19 17:09 mherrmann

This has been built successfully in the past couple of weeks? I am wondering if some of the recent crazy bugs released by for windows 10 could have messed something up. I have used fbs as recently as a couple of months ago and had no issues with either Windows 7 or Windows 10.

sydobrew avatar Sep 17 '19 17:09 sydobrew

Yes. fman's last release was 8 days ago.

mherrmann avatar Sep 17 '19 17:09 mherrmann

Keeping this thread going so that maybe someone else can benefit from my ongoing frustration. I have narrowed my problem down to something going on with importing pandas under the WIN10 configuration that is redirecting pointers that then cause fbs to not find the pyinstaller libraries. Not sure if this is a known issue

from fbs_runtime.application_context.PyQt5 import ApplicationContext

import pandas as pd# ||

if name == 'main': appctxt = ApplicationContext() # 1. Instantiate ApplicationContext window = QMainWindow() window.resize(250, 150) window.show() exit_code = appctxt.app.exec_() # 2. Invoke appctxt.app.exec_() sys.exit(exit_code)

simply adding the pandas import statement to the basic startproject file will cause fbs to error during build. with the following error 30903 INFO: Found binding redirects: [] Traceback (most recent call last): File "c:\users\sb\appdata\local\programs\python\python36\lib\runpy.py", line 193, in run_module_as_main "main", mod_spec) File "c:\users\sb\appdata\local\programs\python\python36\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Users\sb\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller.exe_main.py", line 9, in File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller_main.py", line 111, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller_main_.py", line 63, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build exec(code, spec_namespace) File "C:\Users\sb\Documents\EDN\Documents\PDN\import\target\PyInstaller\MyApp.spec", line 17, in noarchive=True) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 243, in init self.postinit() File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in postinit self.assemble() File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 597, in assemble for name, path, typecode in compile_py_files(new_toc, CONF['workpath']): File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\utils\misc.py", line 150, in compile_py_files with open(obj_fnm, 'rb') as fh: FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\sb\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller.exe\main.pyo' Traceback (most recent call last): File "c:\users\sb\appdata\local\programs\python\python36\lib\runpy.py", line 193, in run_module_as_main "main", mod_spec) File "c:\users\sb\appdata\local\programs\python\python36\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Users\sb\AppData\Local\Programs\Python\Python36\Scripts\fbs.exe_main.py", line 9, in File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\fbs_main.py", line 17, in main fbs.cmdline.main() File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\fbs\cmdline.py", line 32, in main fn(*args) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\fbs\builtin_commands_init.py", line 120, in freeze freeze_windows(debug=debug) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\fbs\freeze\windows.py", line 18, in freeze_windows run_pyinstaller(args, debug) File "c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\fbs\freeze_init_.py", line 48, in run_pyinstaller run(args, check=True) File "c:\users\sb\appdata\local\programs\python\python36\lib\subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['pyinstaller', '--name', 'MyApp', '--noupx', '--log-level', 'DEBUG', '--noconfirm', '--icon', 'C:\Users\sb\Documents\EDN\Documents\PDN\import\src\main\icons\Icon.ico', '--distpath', 'C:\Users\sb\Documents\EDN\Documents\PDN\import\target', '--specpath', 'C:\Users\sb\Documents\EDN\Documents\PDN\import\target\PyInstaller', '--workpath', 'C:\Users\sb\Documents\EDN\Documents\PDN\import\target\PyInstaller', '--additional-hooks-dir', 'c:\users\sb\appdata\local\programs\python\python36\lib\site-packages\fbs\freeze\hooks', '--debug', 'all', '--runtime-hook', 'C:\Users\sb\AppData\Local\Temp\tmpt9vorf0g\fbs_pyinstaller_hook.py', 'C:\Users\sb\Documents\EDN\Documents\PDN\import\src\main\python\main.py']' returned non-zero exit status 1.

sydobrew avatar Sep 19 '19 23:09 sydobrew

found this issue documented previously with a pandas import problem . tried the fix documented there but still receiving the same error shown above.

sydobrew avatar Sep 20 '19 00:09 sydobrew

After a couple of builds with different projects it seems that this issue is related to importing modules from files in the same directory as main. Is there a requirement within fbs to only build the main.py file? or are additional python files supposed to be setup as reference files as well configuration files? I intend to do some testing when I get a chance but I haven't seen these specifics within the documentation related to resource files.

sydobrew avatar Nov 04 '19 20:11 sydobrew

Is there a requirement within fbs to only build the main.py file?

No. fbs should handle imports you have in your main file (and other files).

are additional python files supposed to be setup as reference files as well configuration files?

Also no. fbs (actually, PyInstaller) should just handle them.

In short, fbs should be able to handle all imports that take place when you do python path/to/your/main.py.

mherrmann avatar Nov 05 '19 07:11 mherrmann

I'm still struggling with this issue, at one point I was able to complete a build but the problem seems to still be persistent. I have continued to narrow things down and it seems to be some import issue with the QT5 DLLs. Specifically I'm stuck getting the Qt5Core.dll but I imagine it will fail on the others if I could get past this. It seems that the target exe is looking for dll in the path C:\Users\sb\AppData\Local\Programs\Microsoft VS Code\bin\Qt5Core.dll instead of looking in the target path. The dlls exist in the target path in the same directory as the target exe. Is there a way to force the path to look in the target directory?

sydobrew avatar Jan 08 '20 18:01 sydobrew

Here is the full trace

C:\Users\sb\AppData\Local\Programs\Microsoft VS Code\bin\Qt5Core.dll Traceback (most recent call last): File "main.py", line 1, in File "", line 968, in _find_and_load File "", line 957, in _find_and_load_unlocked File "", line 673, in _load_unlocked File "", line 697, in exec_module File "", line 222, in _call_with_frames_removed File "c:\users\sb.conda\envs\rprtopticsss0\lib\site-packages\fbs_runtime\application_context\PyQt5.py", line 24, in from PyQt5.QtGui import QIcon File "", line 968, in _find_and_load File "", line 943, in _find_and_load_unlocked File "", line 222, in _call_with_frames_removed File "", line 968, in _find_and_load File "", line 957, in _find_and_load_unlocked File "", line 673, in load_unlocked File "", line 697, in exec_module File "", line 222, in call_with_frames_removed File "c:\users\sb.conda\envs\rprtopticsss0\lib\site-packages\PyQt5_init.py", line 42, in find_qt() File "c:\users\sb.conda\envs\rprtopticsss0\lib\site-packages\PyQt5_init.py", line 34, in find_qt raise ImportError("unable to find Qt5Core.dll on PATH") ImportError: unable to find Qt5Core.dll on PATH

sydobrew avatar Jan 08 '20 18:01 sydobrew