ChristianSteger/HORAYZON

ImportError in importing horayzon

paolodeidda opened this issue · 4 comments

Hi,
I successfully installed the package following the instructions in the README, however if I then open a python interpreter and import horayzon I got the following message/error:

>>> import horayzon
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "path-of-the-conda-env/lib/python3.10/site-packages/horayzon/__init__.py", line 6, in <module>
    from . import horizon
ImportError: libnetcdf.so.7: cannot open shared object file: No such file or directory

To try to understand the possible reasons, I checked the package folder and saw that there is no horizon.py but only a .so (horizon.cpython-310-x86_64-linux-gnu.so). However, I don't know much about how these files are read by __init__.py.

Do you know by any chance what could be the reason of this error?
Thanks in advance, Paolo.

Update:
I managed to install the package. The problem was in the version of the netcdf4 package. What I did is to create a conda environment with python 3.10 by specifying the netcdf4 version (I took the version 1.5.8, but it could work also with newer versions).

I hope it can be useful in case anybody faces the same problem.
Paolo

Hi @paolodeidda and @ChristianSteger
I experience the same problem (ImportError: libnetcdf.so.7 ...) and followed the steps described above. However, after downgrade to python 3.10 and netcdf4=1.5.8 I have the same error.
Instead of .so.7 there is $/miniconda3/envs/horayzon_all/lib/libnetcdf.so.19 file. As proposed on some forums, I made an attempt to create symbolic link to mimic .so.7
ln -s libnetcdf.so.19 libnetcdf.so.7
which alloed me to proceed further. Some more libs were necessary to provide symbolic links (libcrypto.so.1.0.0, libssl.so.1.0.0, libhdf5.so.10, etc), which helped go through. However, I end up with ImportError: .../site-packages/horayzon/horizon.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK6netCDF5NcVar6putAttERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_, which can be the result of symlinks : -( The process was repeated by my friend on other machine, with the same results).

Please, any hints how could I proceed with conda installation of Horayzon properely?

Hi @jurajbetak,
I don't really know how to solve your problem. But, what I can do is to share the conda environment I'm using as a .yml file (I upload it as a .txt. Since I can't upload a yml here, try renaming the file once downloaded), so that you can try to install the package with:
conda env create -f YML_FILE
Here is the file: env_horayzon.txt
In the yml file there are all the libraries to run the examples + spyder.
Then you can install HORAYZON by downloading the package from github and install it with:
python -m pip install .
I hope it works!
Paolo

@paolodeidda thank you very much for sharing the YML file. It works like a charm now with your conda environment.
I made a comparison of packages with my instance. The key packages (python, netcdf) are the same; however many more packages versions differ. I did not make further analysis; it might be 'somewhere'.