Skip to content
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

Import Problem with netCDF4 DLL and pyinstaller, I do not know what to do #1316

Closed
mtsamorim opened this issue Apr 8, 2024 · 3 comments
Closed

Comments

@mtsamorim
Copy link

Hello guys, I recently created a program that uses several libraries related in some way to geology or geospatial data, and the files that my program reads are .nc or .nc4, it is running perfectly if I run it myself using a command like
python program.py
So I decided to create an executable of it with pyinstaller and at first everything seemed to go well, the program's interface opens perfectly, but when it gets to the part where it appears that it uses netCDF4, which is the part that reads .nc4 files, some kind of error which I am leaving below.

Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter_init
.py", line 1892, in call
File "interface.py", line 251, in
File "interface.py", line 603, in select_variables
File "interface.py", line 49, in init
File "interface.py", line 75, in read_variables_from_netcdf
File "xarray\backends\api.py", line 541, in open_dataset
File "xarray\backends\netCDF4_.py", line 578, in open_dataset
File "xarray\backends\netCDF4_.py", line 349, in open
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "netCDF4_init_.py", line 31, in
ImportError: DLL load failed while importing netCDF4: The specified module could not be found.

I've tried everything when I can, I've already passed several variables on the pyinstaller command line when generating the executable, but even so, when it gets to this part of the program, it gives me this error, would anyone have any idea what it could be and how to fix it? ? I even went so far as to create another environment in conda to install everything again to see if the problem was the previous environment but it continues, I will be extremely grateful if someone helps me with this persistent and annoying error that only happens in the program's executable, as the code is working perfectly

@jswhit
Copy link
Collaborator

jswhit commented Apr 10, 2024

I am not familiar with pyinstaller, but I imagine it's tricky to get it to work correctly when there are many dependencies with C extensions that link external C libraries.

@mtsamorim
Copy link
Author

I am not familiar with pyinstaller, but I imagine it's tricky to get it to work correctly when there are many dependencies with C extensions that link external C libraries.

Could this be it? I really needed this executable, would you have any idea of another way to create an executable or even a family library?

@jswhit
Copy link
Collaborator

jswhit commented Apr 12, 2024

how about a conda environment bundled in a container (like apptainer)?

@jswhit jswhit closed this as completed Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants