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

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

Open
ForrestPi opened this issue Aug 5, 2024 · 2 comments

Comments

@ForrestPi
Copy link

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
Copy link

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

@Krankheit
Copy link

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.

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

No branches or pull requests

3 participants