Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

src/cityhash.cpp:2628:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope #38

Description

@EroData

I was trying to install cityhash while met the following error. Is seems the 'PyUnicode_AsUTF8AndSize' is only supported by python3.x.

Need to mention, I was using 'python -m pip install ', because we need to use python2.

You can find the 'PyUnicode_AsUTF8AndSize' in https://docs.python.org/3/c-api/unicode.html

Anyone can help this?

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Isrc -I/usr/include/python2.7 -c src/cityhash.cpp -o build/temp.linux-x86_64-2.7/src/cityhash.o -O3 -Wno-unused-value -Wno-unused-function
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/cityhash.cpp: In function ‘PyObject* __pyx_pf_8cityhash_CityHash32(PyObject*, PyObject*)’:
src/cityhash.cpp:1603:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 103, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
src/cityhash.cpp:1603:17: note: suggested alternative: ‘PyUnicode_AsUTF8String’
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 103, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
PyUnicode_AsUTF8String
src/cityhash.cpp: In function ‘PyObject
__pyx_pf_8cityhash_2CityHash64(PyObject
, PyObject*)’:
src/cityhash.cpp:1826:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 136, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
src/cityhash.cpp:1826:17: note: suggested alternative: ‘PyUnicode_AsUTF8String’
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 136, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
PyUnicode_AsUTF8String
src/cityhash.cpp: In function ‘PyObject
__pyx_pf_8cityhash_4CityHash64WithSeed(PyObject
, PyObject*, uint64)’:
src/cityhash.cpp:2107:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 171, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
src/cityhash.cpp:2107:17: note: suggested alternative: ‘PyUnicode_AsUTF8String’
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 171, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
PyUnicode_AsUTF8String
src/cityhash.cpp: In function ‘PyObject
__pyx_pf_8cityhash_6CityHash64WithSeeds(PyObject
, PyObject*, uint64, uint64)’:
src/cityhash.cpp:2404:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 207, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
src/cityhash.cpp:2404:17: note: suggested alternative: ‘PyUnicode_AsUTF8String’
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 207, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
PyUnicode_AsUTF8String
src/cityhash.cpp: In function ‘PyObject
__pyx_pf_8cityhash_8CityHash128(PyObject
, PyObject*)’:
src/cityhash.cpp:2628:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 240, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
src/cityhash.cpp:2628:17: note: suggested alternative: ‘PyUnicode_AsUTF8String’
__pyx_t_2 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_2 == ((char const )NULL))) __PYX_ERR(0, 240, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
PyUnicode_AsUTF8String
src/cityhash.cpp: In function ‘PyObject
__pyx_pf_8cityhash_10CityHash128WithSeed(PyObject
, PyObject*, PyObject*)’:
src/cityhash.cpp:2951:17: error: ‘PyUnicode_AsUTF8AndSize’ was not declared in this scope
__pyx_t_4 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_4 == ((char const *)NULL))) __PYX_ERR(0, 279, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
src/cityhash.cpp:2951:17: note: suggested alternative: ‘PyUnicode_AsUTF8String’
__pyx_t_4 = PyUnicode_AsUTF8AndSize(__pyx_v_data, (&__pyx_v_encoding_size)); if (unlikely(__pyx_t_4 == ((char const *)NULL))) __PYX_ERR(0, 279, __pyx_L1_error)
^~~~~~~~~~~~~~~~~~~~~~~
PyUnicode_AsUTF8String
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


ERROR: Failed building wheel for cityhash
Failed to build cityhash
ERROR: Could not build wheels for cityhash which use PEP 517 and cannot be installed directly

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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