Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

AttributeError: module 'numpy' has no attribute 'int' when importing tacto #42

Open
thesofakillers opened this issue Apr 13, 2023 · 2 comments

Comments

@thesofakillers
Copy link

Steps to reproduce

First, install tacto in a fresh environment as instructed

conda create -n reproduce python=3.8 -y
conda activate reproduce
pip install tacto

Then, see if it worked: try running this python script

import tacto

You get the following error:

pybullet build time: Apr 12 2023 14:39:48
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/tacto/__init__.py", line 6, in <module>
    from .renderer import Renderer  # noqa: F401
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/tacto/renderer.py", line 29, in <module>
    import pyrender
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/pyrender/__init__.py", line 10, in <module>
    from .scene import Scene
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/pyrender/scene.py", line 7, in <module>
    import networkx as nx
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/__init__.py", line 117, in <module>
    import networkx.readwrite
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/readwrite/__init__.py", line 15, in <module>
    from networkx.readwrite.graphml import *
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/readwrite/graphml.py", line 314, in <module>
    class GraphML(object):
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/readwrite/graphml.py", line 346, in GraphML
    (np.int, "int"), (np.int8, "int"),
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
@thesofakillers
Copy link
Author

I've found that the culprit of the issue is the dependency on urdfpy, which unfortunately has a hard dependency on networkx 2.2 which doesn't support numpy 1.20 as this support came with networkx 3.0.

Until the issue of the hard dependency is addressed in the urdfpy repo via the currently unmerged PR, users of tacto should either downgrade numpy to <1.20 or simply override the urdfpy networkx requirement.

@gitouni
Copy link

gitouni commented Sep 14, 2023

Steps to reproduce

First, install tacto in a fresh environment as instructed

conda create -n reproduce python=3.8 -y
conda activate reproduce
pip install tacto

Then, see if it worked: try running this python script

import tacto

You get the following error:

pybullet build time: Apr 12 2023 14:39:48
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/tacto/__init__.py", line 6, in <module>
    from .renderer import Renderer  # noqa: F401
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/tacto/renderer.py", line 29, in <module>
    import pyrender
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/pyrender/__init__.py", line 10, in <module>
    from .scene import Scene
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/pyrender/scene.py", line 7, in <module>
    import networkx as nx
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/__init__.py", line 117, in <module>
    import networkx.readwrite
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/readwrite/__init__.py", line 15, in <module>
    from networkx.readwrite.graphml import *
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/readwrite/graphml.py", line 314, in <module>
    class GraphML(object):
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/networkx/readwrite/graphml.py", line 346, in GraphML
    (np.int, "int"), (np.int8, "int"),
  File "/Users/thesofakillers/miniconda3/envs/temp/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

To resolve this issue easily, you just need to delete "(np.int, "int")," in the graphml.py file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants