python - 为什么我不能在 Python 3.x 中使用 python-cjson?

标签 python json python-3.x

我正在寻找标准 json 模块的更好替代品,我找到了 cjson 模块 ( https://github.com/AGProjects/python-cjson/ ),据说它是可用的最快的编码器/解码器。但是,使用 pip3 (Python 3.5) 安装它会返回以下错误(我太笨了,想不通):

           object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
                    ^~~~~~~~~~~~~~~~~~~~~   cjson.c:167:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
           object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
                  ^   cjson.c:169:18: warning: implicit declaration of function ‘PyString_FromStringAndSize’ [-Wimplicit-function-declaration]
           object = PyString_FromStringAndSize(jsondata->ptr+1, len);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:169:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
           object = PyString_FromStringAndSize(jsondata->ptr+1, len);
                  ^   cjson.c:185:39: warning: implicit declaration of function ‘PyString_AsString’ [-Wimplicit-function-declaration]
                                reason ? PyString_AsString(reason) : "bad format");
                                         ^~~~~~~~~~~~~~~~~   cjson.c:185:65: warning: pointer/integer type mismatch in conditional expression
                                reason ? PyString_AsString(reason) : "bad format");
                                                                   ^   cjson.c: In function ‘decode_number’:   cjson.c:295:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       str = PyString_FromStringAndSize(jsondata->ptr, ptr - jsondata->ptr);
           ^   cjson.c:300:18: error: too many arguments to function ‘PyFloat_FromString’
           object = PyFloat_FromString(str, NULL);
                    ^~~~~~~~~~~~~~~~~~   In file included from /usr/include/python3.5m/Python.h:81:0,
                   from cjson.c:5:   /usr/include/python3.5m/floatobject.h:42:24: note: declared here    PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
                          ^~~~~~~~~~~~~~~~~~   cjson.c:302:18: warning: implicit declaration of function ‘PyInt_FromString’ [-Wimplicit-function-declaration]
           object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
                    ^~~~~~~~~~~~~~~~   cjson.c:302:35: warning: implicit declaration of function ‘PyString_AS_STRING’ [-Wimplicit-function-declaration]
           object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
                                     ^~~~~~~~~~~~~~~~~~   cjson.c:302:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
           object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
                  ^   cjson.c: In function ‘encode_string’:   cjson.c:593:14: error: unknown type name ‘PyStringObject’
       register PyStringObject* op = (PyStringObject*) string;
                ^~~~~~~~~~~~~~   cjson.c:593:36: error: ‘PyStringObject’ undeclared (first use in this function)
       register PyStringObject* op = (PyStringObject*) string;
                                      ^~~~~~~~~~~~~~   cjson.c:593:36: note: each undeclared identifier is reported only once for each function it appears in   cjson.c:593:51: error: expected expression before ‘)’ token
       register PyStringObject* op = (PyStringObject*) string;
                                                     ^   cjson.c:594:32: error: request for member ‘ob_size’ in something not a structure or union
       size_t newsize = 2 + 6 * op->ob_size;
                                  ^~   cjson.c:597:11: error: request for member ‘ob_size’ in something not a structure or union
       if (op->ob_size > (PY_SSIZE_T_MAX-2)/6) {
             ^~   cjson.c:602:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       v = PyString_FromStringAndSize((char *)NULL, newsize);
         ^   cjson.c:614:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
           p = PyString_AS_STRING(v);
             ^   cjson.c:616:27: error: request for member ‘ob_size’ in something not a structure or union
           for (i = 0; i < op->ob_size; i++) {
                             ^~   cjson.c:620:19: error: request for member ‘ob_sval’ in something not a structure or union
               c = op->ob_sval[i];
                     ^~   cjson.c:646:9: warning: implicit declaration of function ‘_PyString_Resize’ [-Wimplicit-function-declaration]
           _PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
           ^~~~~~~~~~~~~~~~   cjson.c:646:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
           _PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
                                ^   cjson.c: In function ‘encode_unicode’:   cjson.c:697:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       repr = PyString_FromStringAndSize(NULL, 2 + expandsize*size + 1);
            ^   cjson.c:701:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       p = PyString_AS_STRING(repr);
         ^   cjson.c:709:57: error: subscripted value is neither array nor pointer nor vector
           if ((ch == (Py_UNICODE) PyString_AS_STRING(repr)[0] || ch == '\\')) {
                                                           ^   cjson.c:804:36: error: subscripted value is neither array nor pointer nor vector
       *p++ = PyString_AS_STRING(repr)[0];
                                      ^   cjson.c: In function ‘encode_tuple’:   cjson.c:828:10: error: ‘PyTupleObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
       n = v->ob_size;
            ^~   cjson.c:830:16: warning: implicit declaration of function ‘PyString_FromString’ [-Wimplicit-function-declaration]
           return PyString_FromString("[]");
                  ^~~~~~~~~~~~~~~~~~~   cjson.c:830:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
           return PyString_FromString("[]");
                  ^~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:846:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString("[");
         ^   cjson.c:850:5: warning: implicit declaration of function ‘PyString_ConcatAndDel’ [-Wimplicit-function-declaration]
       PyString_ConcatAndDel(&s, temp);
       ^~~~~~~~~~~~~~~~~~~~~   cjson.c:855:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString("]");
         ^   cjson.c:865:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString(", ");
         ^   cjson.c:868:14: warning: implicit declaration of function ‘_PyString_Join’ [-Wimplicit-function-declaration]
       result = _PyString_Join(s, pieces);
                ^~~~~~~~~~~~~~   cjson.c:868:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       result = _PyString_Join(s, pieces);
              ^   cjson.c: In function ‘encode_list’:   cjson.c:902:10: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
       if (v->ob_size == 0) {
            ^~   cjson.c:903:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
           result = PyString_FromString("[]");
                  ^   cjson.c:913:22: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
       for (i = 0; i < v->ob_size; ++i) {
                        ^~   cjson.c:926:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString("[");
         ^   cjson.c:935:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString("]");
         ^   cjson.c:945:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString(", ");
         ^   cjson.c:948:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       result = _PyString_Join(s, pieces);
              ^   cjson.c: In function ‘encode_dict’:   cjson.c:987:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
           result = PyString_FromString("{}");
                  ^   cjson.c:995:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       colon = PyString_FromString(": ");
             ^   cjson.c:1005:14: warning: implicit declaration of function ‘PyString_Check’ [-Wimplicit-function-declaration]
           if (!PyString_Check(key) && !PyUnicode_Check(key)) {
                ^~~~~~~~~~~~~~   cjson.c:1014:9: warning: implicit declaration of function ‘PyString_Concat’ [-Wimplicit-function-declaration]
           PyString_Concat(&s, colon);
           ^~~~~~~~~~~~~~~   cjson.c:1027:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString("{");
         ^   cjson.c:1036:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString("}");
         ^   cjson.c:1046:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       s = PyString_FromString(", ");
         ^   cjson.c:1049:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       result = _PyString_Join(s, pieces);
              ^   cjson.c: In function ‘encode_object’:   cjson.c:1064:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
           return PyString_FromString("true");
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1066:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
           return PyString_FromString("false");
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1068:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
           return PyString_FromString("null");
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1076:20: warning: return makes pointer from integer without a cast [-Wint-conversion]
               return PyString_FromString("NaN");
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1079:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
                   return PyString_FromString("Infinity");
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1081:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
                   return PyString_FromString("-Infinity");
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1086:16: warning: implicit declaration of function ‘PyInt_Check’ [-Wimplicit-function-declaration]
       } else if (PyInt_Check(object) || PyLong_Check(object)) {
                  ^~~~~~~~~~~   cjson.c: In function ‘JSON_decode’:   cjson.c:1149:9: warning: implicit declaration of function ‘PyString_AsStringAndSize’ [-Wimplicit-function-declaration]
       if (PyString_AsStringAndSize(str, &(jsondata.str), NULL) == -1) {
           ^~~~~~~~~~~~~~~~~~~~~~~~   cjson.c:1155:35: warning: implicit declaration of function ‘PyString_GET_SIZE’ [-Wimplicit-function-declaration]
       jsondata.end = jsondata.str + PyString_GET_SIZE(str);
                                     ^~~~~~~~~~~~~~~~~   cjson.c: In function ‘initcjson’:   cjson.c:1206:9: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
       m = Py_InitModule3("cjson", cjson_methods, module_doc);
           ^~~~~~~~~~~~~~   cjson.c:1206:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       m = Py_InitModule3("cjson", cjson_methods, module_doc);
         ^   cjson.c:1209:9: warning: ‘return’ with no value, in function returning non-void
           return;
           ^~~~~~   cjson.c:1202:1: note: declared here    initcjson(void)    ^~~~~~~~~   cjson.c:1213:9: warning: ‘return’ with no value, in function returning non-void
           return;
           ^~~~~~   cjson.c:1202:1: note: declared here    initcjson(void)    ^~~~~~~~~   cjson.c:1219:9: warning: ‘return’ with no value, in function returning non-void
           return;
           ^~~~~~   cjson.c:1202:1: note: declared here    initcjson(void)    ^~~~~~~~~   cjson.c:1225:9: warning: ‘return’ with no value, in function returning non-void
           return;
           ^~~~~~   cjson.c:1202:1: note: declared here    initcjson(void)    ^~~~~~~~~   error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
     ----------------------------------------   Failed building wheel for python-cjson   Running setup.py clean for python-cjson Failed to build python-cjson Installing collected packages: python-cjson   Running setup.py install for python-cjson ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3pu8hloy/python-cjson/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-zp1kxfa_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    running build_ext
    building 'cjson' extension
    creating build
    creating build/temp.linux-x86_64-3.5
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-7CCmgg/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMODULE_VERSION=1.2.1 -I/usr/include/python3.5m -c cjson.c -o build/temp.linux-x86_64-3.5/cjson.o
    cjson.c: In function ‘decode_string’:
    cjson.c:167:18: warning: implicit declaration of function ‘PyString_DecodeEscape’ [-Wimplicit-function-declaration]
             object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
                      ^~~~~~~~~~~~~~~~~~~~~
    cjson.c:167:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL);
                    ^
    cjson.c:169:18: warning: implicit declaration of function ‘PyString_FromStringAndSize’ [-Wimplicit-function-declaration]
             object = PyString_FromStringAndSize(jsondata->ptr+1, len);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:169:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             object = PyString_FromStringAndSize(jsondata->ptr+1, len);
                    ^
    cjson.c:185:39: warning: implicit declaration of function ‘PyString_AsString’ [-Wimplicit-function-declaration]
                                  reason ? PyString_AsString(reason) : "bad format");
                                           ^~~~~~~~~~~~~~~~~
    cjson.c:185:65: warning: pointer/integer type mismatch in conditional expression
                                  reason ? PyString_AsString(reason) : "bad format");
                                                                     ^
    cjson.c: In function ‘decode_number’:
    cjson.c:295:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         str = PyString_FromStringAndSize(jsondata->ptr, ptr - jsondata->ptr);
             ^
    cjson.c:300:18: error: too many arguments to function ‘PyFloat_FromString’
             object = PyFloat_FromString(str, NULL);
                      ^~~~~~~~~~~~~~~~~~
    In file included from /usr/include/python3.5m/Python.h:81:0,
                     from cjson.c:5:
    /usr/include/python3.5m/floatobject.h:42:24: note: declared here
     PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
                            ^~~~~~~~~~~~~~~~~~
    cjson.c:302:18: warning: implicit declaration of function ‘PyInt_FromString’ [-Wimplicit-function-declaration]
             object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
                      ^~~~~~~~~~~~~~~~
    cjson.c:302:35: warning: implicit declaration of function ‘PyString_AS_STRING’ [-Wimplicit-function-declaration]
             object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
                                       ^~~~~~~~~~~~~~~~~~
    cjson.c:302:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10);
                    ^
    cjson.c: In function ‘encode_string’:
    cjson.c:593:14: error: unknown type name ‘PyStringObject’
         register PyStringObject* op = (PyStringObject*) string;
                  ^~~~~~~~~~~~~~
    cjson.c:593:36: error: ‘PyStringObject’ undeclared (first use in this function)
         register PyStringObject* op = (PyStringObject*) string;
                                        ^~~~~~~~~~~~~~
    cjson.c:593:36: note: each undeclared identifier is reported only once for each function it appears in
    cjson.c:593:51: error: expected expression before ‘)’ token
         register PyStringObject* op = (PyStringObject*) string;
                                                       ^
    cjson.c:594:32: error: request for member ‘ob_size’ in something not a structure or union
         size_t newsize = 2 + 6 * op->ob_size;
                                    ^~
    cjson.c:597:11: error: request for member ‘ob_size’ in something not a structure or union
         if (op->ob_size > (PY_SSIZE_T_MAX-2)/6) {
               ^~
    cjson.c:602:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         v = PyString_FromStringAndSize((char *)NULL, newsize);
           ^
    cjson.c:614:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             p = PyString_AS_STRING(v);
               ^
    cjson.c:616:27: error: request for member ‘ob_size’ in something not a structure or union
             for (i = 0; i < op->ob_size; i++) {
                               ^~
    cjson.c:620:19: error: request for member ‘ob_sval’ in something not a structure or union
                 c = op->ob_sval[i];
                       ^~
    cjson.c:646:9: warning: implicit declaration of function ‘_PyString_Resize’ [-Wimplicit-function-declaration]
             _PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
             ^~~~~~~~~~~~~~~~
    cjson.c:646:30: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
             _PyString_Resize(&v, (int) (p - PyString_AS_STRING(v)));
                                  ^
    cjson.c: In function ‘encode_unicode’:
    cjson.c:697:10: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         repr = PyString_FromStringAndSize(NULL, 2 + expandsize*size + 1);
              ^
    cjson.c:701:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         p = PyString_AS_STRING(repr);
           ^
    cjson.c:709:57: error: subscripted value is neither array nor pointer nor vector
             if ((ch == (Py_UNICODE) PyString_AS_STRING(repr)[0] || ch == '\\')) {
                                                             ^
    cjson.c:804:36: error: subscripted value is neither array nor pointer nor vector
         *p++ = PyString_AS_STRING(repr)[0];
                                        ^
    cjson.c: In function ‘encode_tuple’:
    cjson.c:828:10: error: ‘PyTupleObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
         n = v->ob_size;
              ^~
    cjson.c:830:16: warning: implicit declaration of function ‘PyString_FromString’ [-Wimplicit-function-declaration]
             return PyString_FromString("[]");
                    ^~~~~~~~~~~~~~~~~~~
    cjson.c:830:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
             return PyString_FromString("[]");
                    ^~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:846:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString("[");
           ^
    cjson.c:850:5: warning: implicit declaration of function ‘PyString_ConcatAndDel’ [-Wimplicit-function-declaration]
         PyString_ConcatAndDel(&s, temp);
         ^~~~~~~~~~~~~~~~~~~~~
    cjson.c:855:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString("]");
           ^
    cjson.c:865:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString(", ");
           ^
    cjson.c:868:14: warning: implicit declaration of function ‘_PyString_Join’ [-Wimplicit-function-declaration]
         result = _PyString_Join(s, pieces);
                  ^~~~~~~~~~~~~~
    cjson.c:868:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         result = _PyString_Join(s, pieces);
                ^
    cjson.c: In function ‘encode_list’:
    cjson.c:902:10: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
         if (v->ob_size == 0) {
              ^~
    cjson.c:903:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             result = PyString_FromString("[]");
                    ^
    cjson.c:913:22: error: ‘PyListObject {aka struct <anonymous>}’ has no member named ‘ob_size’; did you mean ‘ob_base’?
         for (i = 0; i < v->ob_size; ++i) {
                          ^~
    cjson.c:926:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString("[");
           ^
    cjson.c:935:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString("]");
           ^
    cjson.c:945:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString(", ");
           ^
    cjson.c:948:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         result = _PyString_Join(s, pieces);
                ^
    cjson.c: In function ‘encode_dict’:
    cjson.c:987:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
             result = PyString_FromString("{}");
                    ^
    cjson.c:995:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         colon = PyString_FromString(": ");
               ^
    cjson.c:1005:14: warning: implicit declaration of function ‘PyString_Check’ [-Wimplicit-function-declaration]
             if (!PyString_Check(key) && !PyUnicode_Check(key)) {
                  ^~~~~~~~~~~~~~
    cjson.c:1014:9: warning: implicit declaration of function ‘PyString_Concat’ [-Wimplicit-function-declaration]
             PyString_Concat(&s, colon);
             ^~~~~~~~~~~~~~~
    cjson.c:1027:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString("{");
           ^
    cjson.c:1036:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString("}");
           ^
    cjson.c:1046:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         s = PyString_FromString(", ");
           ^
    cjson.c:1049:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         result = _PyString_Join(s, pieces);
                ^
    cjson.c: In function ‘encode_object’:
    cjson.c:1064:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
             return PyString_FromString("true");
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1066:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
             return PyString_FromString("false");
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1068:16: warning: return makes pointer from integer without a cast [-Wint-conversion]
             return PyString_FromString("null");
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1076:20: warning: return makes pointer from integer without a cast [-Wint-conversion]
                 return PyString_FromString("NaN");
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1079:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
                     return PyString_FromString("Infinity");
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1081:24: warning: return makes pointer from integer without a cast [-Wint-conversion]
                     return PyString_FromString("-Infinity");
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1086:16: warning: implicit declaration of function ‘PyInt_Check’ [-Wimplicit-function-declaration]
         } else if (PyInt_Check(object) || PyLong_Check(object)) {
                    ^~~~~~~~~~~
    cjson.c: In function ‘JSON_decode’:
    cjson.c:1149:9: warning: implicit declaration of function ‘PyString_AsStringAndSize’ [-Wimplicit-function-declaration]
         if (PyString_AsStringAndSize(str, &(jsondata.str), NULL) == -1) {
             ^~~~~~~~~~~~~~~~~~~~~~~~
    cjson.c:1155:35: warning: implicit declaration of function ‘PyString_GET_SIZE’ [-Wimplicit-function-declaration]
         jsondata.end = jsondata.str + PyString_GET_SIZE(str);
                                       ^~~~~~~~~~~~~~~~~
    cjson.c: In function ‘initcjson’:
    cjson.c:1206:9: warning: implicit declaration of function ‘Py_InitModule3’ [-Wimplicit-function-declaration]
         m = Py_InitModule3("cjson", cjson_methods, module_doc);
             ^~~~~~~~~~~~~~
    cjson.c:1206:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
         m = Py_InitModule3("cjson", cjson_methods, module_doc);
           ^
    cjson.c:1209:9: warning: ‘return’ with no value, in function returning non-void
             return;
             ^~~~~~
    cjson.c:1202:1: note: declared here
     initcjson(void)
     ^~~~~~~~~
    cjson.c:1213:9: warning: ‘return’ with no value, in function returning non-void
             return;
             ^~~~~~
    cjson.c:1202:1: note: declared here
     initcjson(void)
     ^~~~~~~~~
    cjson.c:1219:9: warning: ‘return’ with no value, in function returning non-void
             return;
             ^~~~~~
    cjson.c:1202:1: note: declared here
     initcjson(void)
     ^~~~~~~~~
    cjson.c:1225:9: warning: ‘return’ with no value, in function returning non-void
             return;
             ^~~~~~
    cjson.c:1202:1: note: declared here
     initcjson(void)
     ^~~~~~~~~
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3pu8hloy/python-cjson/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record /tmp/pip-zp1kxfa_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-3pu8hloy/python-cjson/

谢谢。

最佳答案

根据 py3readiness.org ,目前没有对 python-cjson 的 Python3 支持。

也许你想看看ujson而是 ( benchmark )。

您可以通过pip install ujson 安装它。

关于python - 为什么我不能在 Python 3.x 中使用 python-cjson?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43565450/

相关文章:

python - 如何在 Python 中使用 Pandas 从特定列中查找重复行元素的最大绝对值并显示行和列索引

python - x 轴为 24 小时的条形图,日期时间数据仅为本部分的开头

python - Pygame 按住键

javascript - 当我尝试使用 vue js 显示 JSON 数据时,Selectpicker 不工作?

javascript - 让 Discord Bot 链接另一个 channel

python - 如何在 Celery 任务中使用自动重试记录异常

python 3 : Integer not repeated

python-3.x - 可以将我的临时文件放入我的应用程序中的 tmp/目录吗?

python - 将 pandas 数据帧传递给 fastapi

javascript - json-schema 附加元数据