Attribute Error: module 'illustris_python' has no attribute 'groupcat'

Daniel Minyety
  • 1
  • 30 Jan '23

Hello,

I am testing and running the Illustris python scripts in Jupyter Notebooks and I keep getting the error that the module illustris python has no attribute 'groupcat' or 'snapshot'.
I have a feeling it has something to do with the file/directory I am using, here is the first piece of code that results in a system error:

# Run the full directory
illustris_python = os.path.split(illustris_python)[0]
nose_args = [sys.argv[0], illustris_python]
if len(sys.argv) > 1:
    nose_args.extend(sys.argv[1:])
    # print("nose_args = ", nose_args)
    result = nose.run(argv=nose_args)
Usage: ipykernel_launcher.py [options]

ipykernel_launcher.py: error: no such option: -f

I'm not sure what this is due to. And then here is the next code that results in the attribute error"

#basePath = './Illustris-3/output/'
basePath = './output/'
fields = ['GroupPos','GroupVel']
groups = il.groupcat.loadHalos(basePath,135,fields=fields)
AttributeError: module 'illustris_python' has no attribute 'groupcat'

This occurs even after I have defined all of the test group halos and snapshots from the groupcat_test.py and snapshot_test.py scripts. I have double checked that all the Illlustris python scripts are in the correct folder titled illustris_python.

What do I need to do to solve the Attribute Error?

Kind Regards,
Daniel

Dylan Nelson
  • 30 Jan '23

Some sort of path issue. Did you install via pip, or did you just download the files and put them in a folder?

Daniel Minyety
  • 30 Jan '23

Hi Dylan,

Thank you for your response. I installed via pip

Dylan Nelson
  • 30 Jan '23

Exactly as in the README i.e.

git clone git@github.com:illustristng/illustris_python.git
cd illustris_python
pip install .

?

Daniel Minyety
  • 30 Jan '23

Yes, I installed the exact same code as in the README

Dylan Nelson
  • 1
  • 31 Jan '23

What do you see when you type the following:

$ ipython
Python 3.9.7 (default, Sep 16 2021, 13:09:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import illustris_python

In [2]: illustris_python.__path__
Out[2]: ['/home/dnelson/illustris_release/illustris_python/illustris_python']

In [3]: dir(illustris_python)
Out[3]:
['__all__',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'groupcat',
 'lhalotree',
 'snapshot',
 'sublink',
 'util']
Daniel Minyety
  • 1
  • 31 Jan '23

This is what results when I type the following:

ipython
Traceback (most recent call last):
  File "/Users/lab/Ureka/python/bin/ipython", line 4, in <module>
    from IPython import start_ipython
ImportError: No module named IPython
Python 3.9.7 (default, Sep 16 2021, 13:09:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import illustris_python

In [2]: illustris_python.__path__
Out[2]: ['/home/dnelson/illustris_release/illustris_python/illustris_python']

In [3]: dir(illustris_python)
Out[3]:
['__all__',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'groupcat',
 'lhalotree',
 'snapshot',
 'sublink',
 'util']2 [MilkyWay:~] lab:Python 3.9.7 (default, Sep 16 2021, 13:09:58)
Badly placed ()'s.
3 [MilkyWay:~] lab:Type 'copyright', 'credits' or 'license' for more information 
/usr/bin/Type: line 4: type: copyright,: not found
/usr/bin/Type: line 4: type: credits: not found
/usr/bin/Type: line 4: type: or: not found
/usr/bin/Type: line 4: type: license: not found
for is a shell keyword
more is /usr/bin/more
/usr/bin/Type: line 4: type: information: not found
4 [MilkyWay:~] lab:IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
IPython: Command not found.
5 [MilkyWay:~] lab:
5 [MilkyWay:~] lab:In [1]: import illustris_python
In: No match.
6 [MilkyWay:~] lab:
6 [MilkyWay:~] lab:In [2]: illustris_python.__path__
In: No match.
7 [MilkyWay:~] lab:Out[2]: ['/home/dnelson/illustris_release/illustris_python/illustris_python']
Out[2]:: Too many arguments.
8 [MilkyWay:~] lab:
8 [MilkyWay:~] lab:In [3]: dir(illustris_python)
Badly placed ()'s.
9 [MilkyWay:~] lab:Out[3]:
10 [MilkyWay:~] lab:['__all__',
[__all__,: Command not found.
11 [MilkyWay:~] lab: '__builtins__',
__builtins__,: Command not found.
12 [MilkyWay:~] lab: '__cached__',
__cached__,: Command not found.
13 [MilkyWay:~] lab: '__doc__',
__doc__,: Command not found.
14 [MilkyWay:~] lab: '__file__',
__file__,: Command not found.
15 [MilkyWay:~] lab: '__loader__',
__loader__,: Command not found.
16 [MilkyWay:~] lab: '__name__',
__name__,: Command not found.
17 [MilkyWay:~] lab: '__package__',
__package__,: Command not found.
18 [MilkyWay:~] lab: '__path__',
__path__,: Command not found.
19 [MilkyWay:~] lab: '__spec__',
__spec__,: Command not found.
20 [MilkyWay:~] lab: 'groupcat',
groupcat,: Command not found.
21 [MilkyWay:~] lab: 'lhalotree',
lhalotree,: Command not found.
22 [MilkyWay:~] lab: 'snapshot',
snapshot,: Command not found.
23 [MilkyWay:~] lab: 'sublink',
sublink,: Command not found.
24 [MilkyWay:~] lab: 'util']

I have also double checked that I installed via pip and I get the output saying that illustris_python already exists.

Dylan Nelson
  • 1 Feb '23

It appears that you python installation is broken, I'm afraid I cannot really help with that.

(1) ImportError: No module named IPython indicates a larger problem.
(2) You have /home/dnelson/ in illustris_python.__path__? This doesn't make any sense to me.
(3) These MilkyWay errors at the end are strange.

I would suggest you contact your sysadmin, or (i) reinstall a fresh python using Anaconda, (ii) set up a clean environment, and (iii) then proceed.

Juan Diego Uribe Carrillo
  • 8 Oct

I'm getting the same error as @Daniel Minyety, however when I type the commands @Dylan Nelson I get the following results:

In  [1]: import illustris_python as il

In  [2]: il.__path__
Out [2]: _NamespacePath(['/vera/u/judigoan/illustris_python', '/vera/u/judigoan/illustris_python'])

In  [3]: dir(il)
Out [3]: 
['__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__']

It seems like I'm missing a couple of things from my installation of illustris_python. Any suggesttions?
Thank you!

Dylan Nelson
  • 8 Oct

How did you install it? Perhaps reinstall.

  • Page 1 of 1