-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pyinstaller failing on numcodecs blosc import #291
Pyinstaller failing on numcodecs blosc import #291
Comments
Does it work for you without PyInstaller? |
Yes - although I don't know if blosc is being called directly but it's the exact same code so I think the import should be firing. |
There's also a fair amount of indirection in the traceback above. Can we reproduce this with just Zarr or maybe better just Numcodecs? |
I'll have a go tomorrow - I'm not actually familiar with numcodecs but I'll cobble something together. |
Sounds good :) For clarity am suggesting something like Anyways just trying to cull this reproducer down into something where it is easier to pinpoint where things are going wrong |
Runs no errors but via pyinstaller I get Traceback (most recent call last): |
in conda and another clean install of vanilla python 3.9.7 |
So it sounds like Blosc did not get packaged in this case, but the data being loaded requires it. Does that sound about right? |
Well yes and no - in the minimal example it just imports it, that is the whole program. Maybe since it isn't used in the one I just run that isn't a problem, but packaging requires them all? I'm not an expert on either I'm afraid. But broadly yes, I guess it that is the case, I think they get used in loading CZIs |
cc: @JacksonMaxfield especially re: napari/napari#665 (comment) |
I don't believe we use numcodecs for CZI loading..... We don't even list numcodecs as a dependency for Which means it's coming from Do I need to update that zarr version pin? |
Hmmm.... possibly. Or at least to add a matching numcodecs pin. Do you know why the pin is in place? Is it for matching Python versions? |
Why the zarr pin is there? Because we need it for chunked tifffile loading. |
Ah, but |
From this earlier comment it does seem more like a packaging issue on windows or something similar. |
@joshmoore 2.10.3 if that helps. |
Extremely late to the party here, but I believe you can fix the PyInstaller builds by adding the list generated by I've not tested the specific example above, but having |
Thanks for chiming in David! 😄 Is there anything special we need to do with PyInstaller to make sure the shared objects in Numcodecs are handled correctly? |
I'm not familiar with how numcodecs works, but PyInstaller should pack the entire thing if using the hook method above. Looking at the package I don't see anything within numcodecs that would obviously cause problems. Missing imports are a common theme with PyInstaller, and might be expected in situations where your program could need an ambiguous codec to read a file but it's never explicitly imported within your code. Good luck! |
Thanks again David! 🙏 |
Thanks for getting back - now I'm back from holiday I'll give this a try and report back (although it might take a while) |
Adding all of the numcodecs submodules as hidden imports fixed the issue for me! Perhaps an official pyinstaller hook should be created for numcodecs? |
In fact, it looks like this works for the hook file ( from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules("numcodecs") If you put that file in your current directory, and add |
It would be good to understand why that hook is needed. IOW is there something we should be doing in the packaging of Numcodecs to obviate the need for that hook? |
In my testing Pyinstaller typically missed I believe Pyinstaller provides some methods for declaring these imports for them within your package, but I've not tried it myself. |
Interesting. Good to know that FWIW PyInstaller includes a number of hooks itself. So another option may be for someone interested in this to add the hook upstream. |
I can't confirm whether other modules exhibit the same issue, it's one of those things where it was faster to force bundle the whole package than to repeatedly build my app and tweak until every hidden import is discovered. It's not a large package so I wasn't overly concerned about packaging extra content. |
numcodecs.compat_ext is only imported from pyx files, so it is missed. See zarr-developers/numcodecs#291 for more information. Repo: https://github.com/zarr-developers/numcodecs Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
I tried having a single hidden import of I added the hook as a PR, which should fix this issue: pyinstaller/pyinstaller-hooks-contrib#420 That |
numcodecs.compat_ext is only imported from pyx files, so it is missed. See zarr-developers/numcodecs#291 for more information. Repo: https://github.com/zarr-developers/numcodecs Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
numcodecs.compat_ext is only imported from pyx files, so it is missed. See zarr-developers/numcodecs#291 for more information. Repo: https://github.com/zarr-developers/numcodecs
Hi all. pyinstaller/pyinstaller-hooks-contrib#420 was merged. I gave it a try on my local example, and it seems to have fixed the issue! Until a new release comes out, I guess we can install from master via a command like |
Thanks @psavery! 😄 |
Minimal, reproducible code sample, a copy-pastable example if possible
then
Problem description
I'm using aicsimageio for loading CZI files and I'm trying to package it up into a stand-alone app for one of our EngD students to use.
The only reference I could find to my exact problem is this:
napari/napari#665 (comment)
And I couldn't find the ticket. So I thought I would raise it.
The issue is that the app works when run as a script, the app functions completely as expected. When I package it up I get the following error:
Traceback (most recent call last):
File "main.py", line 3, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "control_scheme_python.py", line 11, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "chunking_logic.py", line 6, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "aicsimageio_init_.py", line 6, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "aicsimageio\aics_image.py", line 10, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xarray_init_.py", line 1, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xarray\tutorial.py", line 13, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xarray\backends_init_.py", line 17, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xarray\backends\zarr.py", line 22, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "zarr_init_.py", line 2, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "zarr\codecs.py", line 3, in
ImportError: cannot import name 'Blosc' from 'numcodecs' (C:\Users\iris\AppData\Local\Temp_MEI63202\numcodecs_init_.pyc)
I guess the expected behavior is: it runs.
I had a c++ installer (MS VS build tools 2019) and the build from pip for aicsimageio ran without error - including seeing the numcodecs build.
The most desirable and quickest solution I'm hoping for is that someone points out a stupid mistake I've made and I fix it easily :)
Version and installation information
Please provide the following:
numcodecs.__version__
= 0.9.1bug_requirements.txt
I've had it on other versions of python and conda too.
Thanks
The text was updated successfully, but these errors were encountered: