Skip to content

error: incompatible type for argument 1 of ‘_Py_HashDouble #8

Description

@kimdn

Question:

I am installing AutoMicroED and run into problems with python in the NumPy build process. Part of the problem may be that I am installing it in WSL (Windows subsystem for linux), until I can buy a Linux workstation.

I installed minconda3 for another Gonan lab utility mrc2smv and maybe this version is conflicting with your software?

Here is part of the error message I get. Do you have any suggestions?

umpy/core/src/multiarray/scalarapi.c: In function ‘PyArray_Scalar’: numpy/core/src/multiarray/scalarapi.c:759:13: warning: ‘ob_shash’ is deprecated [-Wdeprecated-declarations] 759 | ((PyStringObject *)obj)->ob_shash = -1; | ^ In file included from /home/jbacsa/miniconda3/include/python3.11/bytesobject.h:62, from /home/jbacsa/miniconda3/include/python3.11/Python.h:50, from numpy/core/src/multiarray/scalarapi.c:2: /home/jbacsa/miniconda3/include/python3.11/cpython/bytesobject.h:7:35: note: declared here 7 | Py_DEPRECATED(3.11) Py_hash_t ob_shash; | ^~~~~~~~ gcc: numpy/core/src/multiarray/iterators.c gcc: numpy/core/src/multiarray/nditer_pywrap.c gcc: numpy/core/src/multiarray/sequence.c gcc: numpy/core/src/multiarray/getset.c gcc: build/src.linux-x86_64-3.11/numpy/core/src/multiarray/scalartypes.c gcc: numpy/core/src/multiarray/shape.c numpy/core/src/multiarray/scalartypes.c.src: In function ‘float_arrtype_hash’: numpy/core/src/multiarray/scalartypes.c.src:2967:27: error: incompatible type for argument 1 of ‘_Py_HashDouble’ 2967 | return _Py_HashDouble((double) PyArrayScalar_VAL(obj, @name@)); In file included from /home/jbacsa/miniconda3/include/python3.11/Python.h:47, from numpy/core/src/multiarray/scalartypes.c.src:3: /home/jbacsa/miniconda3/include/python3.11/pyhash.h:10:38: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘double’ 10 | PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double); | ^~~~~~~~~~ numpy/core/src/multiarray/scalartypes.c.src:2967:12: error: too few arguments to function ‘_Py_HashDouble’ 2967 | return _Py_HashDouble((double) PyArrayScalar_VAL(obj, @name@)); | ^~~~~~~~~~~~~~ In file included from /home/jbacsa/miniconda3/include/python3.11/Python.h:47, from numpy/core/src/multiarray/scalartypes.c.src:3: /home/jbacsa/miniconda3/include/python3.11/pyhash.h:10:23: note: declared here 10 | PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double); | ^~~~~~~~~~~~~~ numpy/core/src/multiarray/scalartypes.c.src: In function ‘cfloat_arrtype_hash’: numpy/core/src/multiarray/scalartypes.c.src:2975:31: error: incompatible type for argument 1 of ‘_Py_HashDouble

-->
GPT-4 answer:

The errors and warnings you're encountering seem to be related to changes in the Python 3.11 API that affect how NumPy interacts with it.

The warning about ob_shash being deprecated is due to a change in the Python API. The ob_shash attribute of PyStringObject is marked as deprecated in Python 3.11. This means that the code in NumPy is using a feature that is no longer recommended and may be removed in future versions of Python.

The errors in numpy/core/src/multiarray/scalartypes.c.src are related to the _Py_HashDouble function. The first error suggests a type mismatch where a double is passed instead of the expected PyObject *. The second error indicates that _Py_HashDouble is being called with too few arguments. In Python 3.11, _Py_HashDouble seems to have a different signature requiring additional parameters.

To address these issues:

For the deprecation warning, you might need to update the NumPy code to avoid using deprecated features. Check if a newer version of NumPy has fixed these compatibility issues with Python 3.11.

For the errors, review the changes in Python 3.11 related to the _Py_HashDouble function and adjust the NumPy source code accordingly. This might involve passing the correct type of arguments and ensuring the right number of arguments are provided.

If you are working on a project that requires stability and compatibility, consider using an earlier version of Python where NumPy is fully compatible. If you are contributing to NumPy or need to use Python 3.11, you may need to patch the source code to accommodate these changes.

Remember that working with the latest versions of programming languages and libraries can sometimes lead to such compatibility issues, and part of the work involves adapting to or waiting for updates in the ecosystem.

--> Doo Nam answer:
I've never seen this error message.
But based on GPT-4 message, numpy version may need to be fixed.
I used numpy 1.26.2 and python 3.9 for AutoMicroED running.
Can you try these versions?

--> Irina answer:
This HashDouble error and solution to it can be found here:
https://bugzilla.redhat.com/show_bug.cgi?id=1958052

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions