Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy 2.x not supported #288

Open
ZamboniMarco99 opened this issue Jul 10, 2024 · 1 comment · May be fixed by #292
Open

Numpy 2.x not supported #288

ZamboniMarco99 opened this issue Jul 10, 2024 · 1 comment · May be fixed by #292

Comments

@ZamboniMarco99
Copy link

ZamboniMarco99 commented Jul 10, 2024

I think this is quite a urgent issue since new installations of pyrender break.

The new major release of numpy brings braking changes in the api making pyrender not compatible with it.

A quick fix could be giving an upper bound to the numpy dependency in setup.py

For example this code raise an AttributeError when pyrender try to use np.infty:

import trimesh
import pyrender

mesh = trimesh.load(file)
scene = pyrender.Scene.from_trimesh_scene(mesh_glb, bg_color=[1.0, 1.0, 1.0])
pyrender.Viewer(scene)

Traceback:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File ".../.venv/lib/python3.10/site-packages/pyrender/viewer.py", line 300, in __init__
    zfar = max(scene.scale * 10.0, DEFAULT_Z_FAR)
  File ".../.venv/lib/python3.10/site-packages/pyrender/scene.py", line 254, in scale
    return np.linalg.norm(self.extents)
  File ".../.venv/lib/python3.10/site-packages/pyrender/scene.py", line 248, in extents
    return np.diff(self.bounds, axis=0).reshape(-1)
  File ".../.venv/lib/python3.10/site-packages/pyrender/scene.py", line 226, in bounds
    corners_local = trimesh.bounds.corners(mesh.bounds)
  File ".../.venv/lib/python3.10/site-packages/pyrender/mesh.py", line 87, in bounds
    bounds = np.array([[np.infty, np.infty, np.infty],
  File ".../.venv/lib/python3.10/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.infty` was removed in the NumPy 2.0 release. Use `np.inf` instead.. Did you mean: 'info'?

For full documentation here the contents of my venv:

Package                   Version
------------------------- -----------
addict                    2.4.0
attrs                     23.2.0
blinker                   1.8.2
certifi                   2024.7.4
charset-normalizer        3.3.2
click                     8.1.7
configargparse            1.7
contourpy                 1.2.1
cycler                    0.12.1
dash                      2.17.1
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0
fastjsonschema            2.20.0
flask                     3.0.3
fonttools                 4.53.1
freetype-py               2.4.0
idna                      3.7
imageio                   2.34.2
importlib-metadata        8.0.0
itsdangerous              2.2.0
jinja2                    3.1.4
joblib                    1.4.2
jsonschema                4.23.0
jsonschema-specifications 2023.12.1
jupyter-core              5.7.2
kiwisolver                1.4.5
markupsafe                2.1.5
matplotlib                3.9.1
nbformat                  5.10.4
nest-asyncio              1.6.0
networkx                  3.3
numpy                     2.0.0
open3d                    0.18.0
packaging                 24.1
pandas                    2.2.2
pillow                    10.4.0
platformdirs              4.2.2
plotly                    5.22.0
pyglet                    2.0.15
pyopengl                  3.1.0
pyparsing                 3.1.2
pyquaternion              0.9.9
pyrender                  0.1.45
python-dateutil           2.9.0.post0
pytz                      2024.1
pyyaml                    6.0.1
referencing               0.35.1
requests                  2.32.3
retrying                  1.3.4
rpds-py                   0.19.0
scikit-learn              1.5.1
scipy                     1.14.0
setuptools                70.3.0
six                       1.16.0
tenacity                  8.5.0
threadpoolctl             3.5.0
tqdm                      4.66.4
traitlets                 5.14.3
trimesh                   4.4.2
typing-extensions         4.12.2
tzdata                    2024.1
urllib3                   2.2.2
werkzeug                  3.0.3
zipp                      3.19.2
@ZamboniMarco99
Copy link
Author

From the user perspective a workaround is to specify a compatible numpy version in your requirements.txt or installation command, for example:

pip install numpy==1.26

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

Successfully merging a pull request may close this issue.

1 participant