HONDAFILE error while loading flux in v1.0.1
Description
When trying to import flux (from km3flux import flux
) with v1.0.1, I got the following error:
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from km3flux import flux
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/ven/lib/python3.8/site-packages/km3flux/flux.py", line 12, in <module>
from km3flux.data import (
ImportError: cannot import name 'HONDAFILE' from 'km3flux.data' (/tmp/ven/lib/python3.8/site-packages/km3flux/data/__init__.py)
My understanding of the problem comes from the presence of a data
directory and a data.py
file in the km3flux
directory:
(ven) vpestel@vpestel-X1:/tmp$ ll /tmp/ven/lib/python3.8/site-packages/km3flux/
total 68K
-rw-rw-r-- 1 vpestel vpestel 1,3K juin 7 13:21 aeff.py
drwxrwxr-x 7 vpestel vpestel 4,0K juin 7 13:21 data
-rw-rw-r-- 1 vpestel vpestel 5,3K juin 7 13:21 data.py
-rw-rw-r-- 1 vpestel vpestel 17K juin 7 13:21 flux.py
-rw-rw-r-- 1 vpestel vpestel 111 juin 7 13:21 __init__.py
-rw-rw-r-- 1 vpestel vpestel 5,7K juin 7 13:21 logger.py
drwxrwxr-x 2 vpestel vpestel 4,0K juin 7 13:21 __pycache__
drwxrwxr-x 2 vpestel vpestel 4,0K juin 7 13:21 util
drwxrwxr-x 3 vpestel vpestel 4,0K juin 7 13:21 utils
-rw-rw-r-- 1 vpestel vpestel 142 juin 7 13:21 version.py
-rw-rw-r-- 1 vpestel vpestel 3,6K juin 7 13:21 weights.py
Hence, when you try the flux.py
is imported, it tries to load members of data
:
from km3flux.data import (
[...]
HONDAFILE,
[...]
)
But this import goes to km3flux/data/__init__.py
instead of km3flux/data.py
, where HONDAFILE
is defined.
Fix proposal
Migrate data.py
in km3flux/data
, and import it from km3flux/data/__init__.py
.
Or wait for the new interface in v>=1.0.2 to solve it, which sounds smarter to me !
Reproduction
From a new environment, install km3flux (and importlib-resources, was necessary with my python3.8 setup).
pip install importlib-resources km3flux
Then open the interpreter and try from km3flux import flux