MPI-IS / mesh

MPI-IS Mesh Processing Library
Other
661 stars 151 forks source link

error: cannot convert ‘PyObject*’ {aka ‘_object*’} to ‘const PyArrayObject*’ {aka ‘const tagPyArrayObject_fields*’} #108

Open ForrestPi opened 1 month ago

ForrestPi commented 1 month ago

error occurred

`mesh/src/aabb_normals.cpp:118:37: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields’} 118 npy_intp* v_dims = PyArray_DIMS(py_v); ^~~~
PyObject {aka _object}
In file included from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12, from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/arrayobject.h:5, from mesh/src/aabb_normals.cpp:4: /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1520:35: note: initializing argument 1 of ‘npy_intp PyArray_DIMS(const PyArrayObject)’ 1520 PyArray_DIMS(const PyArrayObject *arr) ~~~~~^~~ mesh/src/aabb_normals.cpp:119:37: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields’} 119 npy_intp* n_dims = PyArray_DIMS(py_n); ^~~~
PyObject {aka _object}
In file included from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12, from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/arrayobject.h:5, from mesh/src/aabb_normals.cpp:4: /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1520:35: note: initializing argument 1 of ‘npy_intp PyArray_DIMS(const PyArrayObject)’ 1520 PyArray_DIMS(const PyArrayObject *arr) ~~~~~^~~ mesh/src/aabb_normals.cpp:132:87: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields’} 132 array<double, 3> m_sample_points=reinterpret_cast<array<double,3>>(PyArray_DATA(py_v)); ^~~~
PyObject {aka _object}
In file included from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12, from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/arrayobject.h:5, from mesh/src/aabb_normals.cpp:4: /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: initializing argument 1 of ‘void PyArray_DATA(const PyArrayObject)’ 1508 PyArray_DATA(const PyArrayObject *arr) ~~~~~^~~ mesh/src/aabb_normals.cpp:133:82: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields’} 133 array<double, 3> m_sample_n=reinterpret_cast<array<double,3>>(PyArray_DATA(py_n)); ^~~~
PyObject {aka _object}
In file included from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12, from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/arrayobject.h:5, from mesh/src/aabb_normals.cpp:4: /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: initializing argument 1 of ‘void PyArray_DATA(const PyArrayObject)’ 1508 PyArray_DATA(const PyArrayObject *arr) ~~~~~^~~ mesh/src/aabb_normals.cpp:150:35: warning: narrowing conversion of ‘S’ from ‘size_t’ {aka ‘long unsigned int’} to ‘npy_intp’ {aka ‘long int’} [-Wnarrowing] 150 npy_intp result1_dims[] = {1, S}; ^ mesh/src/aabb_normals.cpp:154:74: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields’} 154 uint32_t closest_triangles=reinterpret_cast<uint32_t>(PyArray_DATA(result1)); ^~~
PyObject {aka _object}

In file included from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12, from /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/arrayobject.h:5, from mesh/src/aabb_normals.cpp:4: /tmp/pip-build-env-4ggzg8lx/normal/lib/python3.10/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: initializing argument 1 of ‘void PyArray_DATA(const PyArrayObject)’ 1508 | PyArray_DATA(const PyArrayObject arr) | ~~~~~^~~ mesh/src/aabb_normals.cpp:157:36: warning: narrowing conversion of ‘S’ from ‘size_t’ {aka ‘long unsigned int’} to ‘npy_intp’ {aka ‘long int’} [-Wnarrowing] 157 | npy_intp result2_dims[] = {S, 3}; | ^ mesh/src/aabb_normals.cpp:159:71: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields*’}`

which version numpy should work?

forrest-lam commented 2 weeks ago

Same error! Have you found the compatible version of numpy?

Krankheit commented 4 days ago

This issue is probably caused by numpy versions >= 2.0.0 . pip install numpy==1.22.4 And change the 6th line of makefile to: @pip install -r requirements.txt && pip list Then BOOST_INCLUDE_DIRS=boost_path make all, it should work.