ImportError when importing HaloCatalog: cannot import name 'ensure_list' from 'yt.funcs'
I'm running yt 4.0.1 and yt_astro_analysis 1.0.0. I'm trying to import HaloCatalog. I use: from yt_astro_analysis.halo_analysis.api import HaloCatalog but get the error below. On checking funcs.py, it appears that the function 'ensure_list' doesn't exist. Are yt 4.0.1 and yt_astro_analysis 1.0.0 out of sync? I'd be grateful for any suggestions about how to fix this. Cheers Ian ImportError Traceback (most recent call last) /tmp/ipykernel_9530/3924969598.py in <module> 3 import yt 4 import yt_astro_analysis ----> 5 from yt_astro_analysis.halo_analysis.api import HaloCatalog ~/miniconda3/envs/enzo/lib/python3.7/site-packages/yt_astro_analysis/halo_analysis/api.py in <module> 15 16 ---> 17 from yt_astro_analysis.halo_analysis.halo_catalog import \ 18 HaloCatalog 19 ~/miniconda3/envs/enzo/lib/python3.7/site-packages/yt_astro_analysis/halo_analysis/halo_catalog.py in <module> 30 from yt_astro_analysis.halo_analysis.halo_object import \ 31 Halo ---> 32 from yt_astro_analysis.halo_analysis.halo_callbacks import \ 33 callback_registry 34 from yt_astro_analysis.halo_analysis.halo_filters import \ ~/miniconda3/envs/enzo/lib/python3.7/site-packages/yt_astro_analysis/halo_analysis/halo_callbacks.py in <module> 27 from yt.utilities.exceptions import \ 28 YTSphereTooSmall ---> 29 from yt.funcs import \ 30 ensure_list 31 from yt.utilities.logger import ytLogger as mylog ImportError: cannot import name 'ensure_list' from 'yt.funcs' (/home/ian/miniconda3/envs/enzo/lib/python3.7/site-packages/yt/funcs.py)
BTW if I instead use: from yt.extensions.astro_analysis.halo_analysis import HaloCatalog I get an error: Cannot find reference 'astro_analysis' in '__init__.py'
Hi Ian, Unfortunately, yt_astro_analysis 1.0.0 is not compatible with yt 4.0 and later. You'll need to install the development version of yt_astro_analysis. There are instructions on that here: https://yt-astro-analysis.readthedocs.io/en/latest/ Hopefully, we'll have a new release of yt-astro out soon! Britton On Fri, Oct 1, 2021 at 12:50 AM Ian Woodward <ianww@iinet.net.au> wrote:
BTW if I instead use:
from yt.extensions.astro_analysis.halo_analysis import HaloCatalog
I get an error: Cannot find reference 'astro_analysis' in '__init__.py' _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: brittonsmith@gmail.com
I installed the development version from source, giving me the installed package: yt-astro-analysis 1.1.0.dev2 dev_0 <develop> but when I try to import: from yt.extensions.astro_analysis.halo_analysis import HaloCatalog I still get the error: Cannot find reference 'astro_analysis' in '__init__.py' If I instead use: from yt_astro_analysis.halo_analysis import HaloCatalog I get the error: ImportError: cannot import name 'HaloCatalog' from 'yt_astro_analysis.halo_analysis' Should I be importing differently?
Hi Ian, That's strange, both of those imports work for me. Just checking, but have you don't "pip install -e ." inside the source directory? Britton On Fri, Oct 1, 2021 at 10:56 PM Ian Woodward <ianww@iinet.net.au> wrote:
I installed the development version from source, giving me the installed package:
yt-astro-analysis 1.1.0.dev2 dev_0 <develop>
but when I try to import:
from yt.extensions.astro_analysis.halo_analysis import HaloCatalog
I still get the error:
Cannot find reference 'astro_analysis' in '__init__.py'
If I instead use:
from yt_astro_analysis.halo_analysis import HaloCatalog
I get the error:
ImportError: cannot import name 'HaloCatalog' from 'yt_astro_analysis.halo_analysis'
Should I be importing differently? _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: brittonsmith@gmail.com
Ah, apparently not! I thought I had followed the instructions but I just redid the install, and it now works. Sorry about that... Thanks once again! Cheers Ian
participants (2)
-
Britton Smith
-
Ian Woodward