Python安装第三方库,出现‘PyThreadState’ has no member named ‘exc_type’解决方法

最近由于工作需要,要从hbase中读取数据,然后处理过后,展示给用户,在网上搜通过Python的happybase模块可以进行简单快捷的读取,但是在安装happybase,让我非常不开心,具体错误如下:

Collecting happybase
  Using cached https://files.pythonhosted.org/packages/8d/a4/9c1202ad4276d4e845594d534397c07082b90aee68c67f378fac38629e6f/happybase-1.1.0.tar.gz
Requirement already satisfied: six in /usr/local/Python37/lib/python3.7/site-packages (from happybase) (1.11.0)
Collecting thriftpy>=0.3.8 (from happybase)
  Using cached https://files.pythonhosted.org/packages/f4/19/cca118cf7d2087310dbc8bd70dc7df0c1320f2652873a93d06d7ba356d4a/thriftpy-0.3.9.tar.gz
Requirement already satisfied: ply<4.0,>=3.4 in /usr/local/Python37/lib/python3.7/site-packages (from thriftpy>=0.3.8->happybase) (3.11)
Installing collected packages: thriftpy, happybase
  Running setup.py install for thriftpy ... error
    Complete output from command /usr/local/Python37/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4tgdj24y/thriftpy/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-record-14d7fwr3/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/_compat.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/hook.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/rpc.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/server.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/thrift.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/tornado.py -> build/lib.linux-x86_64-3.7/thriftpy
    copying thriftpy/utils.py -> build/lib.linux-x86_64-3.7/thriftpy
    creating build/lib.linux-x86_64-3.7/thriftpy/contrib
    copying thriftpy/contrib/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/contrib
    creating build/lib.linux-x86_64-3.7/thriftpy/parser
    copying thriftpy/parser/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/parser
    copying thriftpy/parser/exc.py -> build/lib.linux-x86_64-3.7/thriftpy/parser
    copying thriftpy/parser/lexer.py -> build/lib.linux-x86_64-3.7/thriftpy/parser
    copying thriftpy/parser/parser.py -> build/lib.linux-x86_64-3.7/thriftpy/parser
    creating build/lib.linux-x86_64-3.7/thriftpy/protocol
    copying thriftpy/protocol/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/protocol
    copying thriftpy/protocol/binary.py -> build/lib.linux-x86_64-3.7/thriftpy/protocol
    copying thriftpy/protocol/compact.py -> build/lib.linux-x86_64-3.7/thriftpy/protocol
    copying thriftpy/protocol/exc.py -> build/lib.linux-x86_64-3.7/thriftpy/protocol
    copying thriftpy/protocol/json.py -> build/lib.linux-x86_64-3.7/thriftpy/protocol
    copying thriftpy/protocol/multiplex.py -> build/lib.linux-x86_64-3.7/thriftpy/protocol
    creating build/lib.linux-x86_64-3.7/thriftpy/transport
    copying thriftpy/transport/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/transport
    copying thriftpy/transport/_ssl.py -> build/lib.linux-x86_64-3.7/thriftpy/transport
    copying thriftpy/transport/socket.py -> build/lib.linux-x86_64-3.7/thriftpy/transport
    copying thriftpy/transport/sslsocket.py -> build/lib.linux-x86_64-3.7/thriftpy/transport
    creating build/lib.linux-x86_64-3.7/thriftpy/contrib/tracking
    copying thriftpy/contrib/tracking/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/contrib/tracking
    copying thriftpy/contrib/tracking/tracker.py -> build/lib.linux-x86_64-3.7/thriftpy/contrib/tracking
    creating build/lib.linux-x86_64-3.7/thriftpy/transport/buffered
    copying thriftpy/transport/buffered/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/transport/buffered
    creating build/lib.linux-x86_64-3.7/thriftpy/transport/framed
    copying thriftpy/transport/framed/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/transport/framed
    creating build/lib.linux-x86_64-3.7/thriftpy/transport/memory
    copying thriftpy/transport/memory/__init__.py -> build/lib.linux-x86_64-3.7/thriftpy/transport/memory
    copying thriftpy/contrib/tracking/tracking.thrift -> build/lib.linux-x86_64-3.7/thriftpy/contrib/tracking
    running build_ext
    building 'thriftpy.transport.cybase' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/thriftpy
    creating build/temp.linux-x86_64-3.7/thriftpy/transport
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/Python37/include/python3.7m -c thriftpy/transport/cybase.c -o build/temp.linux-x86_64-3.7/thriftpy/transport/cybase.o
    thriftpy/transport/cybase.c: In function ‘__Pyx__GetException’:
    thriftpy/transport/cybase.c:3127:22: error: ‘PyThreadState’ has no member named ‘exc_type’
         tmp_type = tstate->exc_type;
                          ^
    thriftpy/transport/cybase.c:3128:23: error: ‘PyThreadState’ has no member named ‘exc_value’
         tmp_value = tstate->exc_value;
                           ^
    thriftpy/transport/cybase.c:3129:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tmp_tb = tstate->exc_traceback;
                        ^
    thriftpy/transport/cybase.c:3130:11: error: ‘PyThreadState’ has no member named ‘exc_type’
         tstate->exc_type = local_type;
               ^
    thriftpy/transport/cybase.c:3131:11: error: ‘PyThreadState’ has no member named ‘exc_value’
         tstate->exc_value = local_value;
               ^
    thriftpy/transport/cybase.c:3132:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tstate->exc_traceback = local_tb;
               ^
    thriftpy/transport/cybase.c: In function ‘__Pyx__ExceptionSwap’:
    thriftpy/transport/cybase.c:3154:22: error: ‘PyThreadState’ has no member named ‘exc_type’
         tmp_type = tstate->exc_type;
                          ^
    thriftpy/transport/cybase.c:3155:23: error: ‘PyThreadState’ has no member named ‘exc_value’
         tmp_value = tstate->exc_value;
                           ^
    thriftpy/transport/cybase.c:3156:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tmp_tb = tstate->exc_traceback;
                        ^
    thriftpy/transport/cybase.c:3157:11: error: ‘PyThreadState’ has no member named ‘exc_type’
         tstate->exc_type = *type;
               ^
    thriftpy/transport/cybase.c:3158:11: error: ‘PyThreadState’ has no member named ‘exc_value’
         tstate->exc_value = *value;
               ^
    thriftpy/transport/cybase.c:3159:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tstate->exc_traceback = *tb;
               ^
    thriftpy/transport/cybase.c: In function ‘__Pyx__ExceptionSave’:
    thriftpy/transport/cybase.c:3178:19: error: ‘PyThreadState’ has no member named ‘exc_type’
         *type = tstate->exc_type;
                       ^
    thriftpy/transport/cybase.c:3179:20: error: ‘PyThreadState’ has no member named ‘exc_value’
         *value = tstate->exc_value;
                        ^
    thriftpy/transport/cybase.c:3180:17: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         *tb = tstate->exc_traceback;
                     ^
    thriftpy/transport/cybase.c: In function ‘__Pyx__ExceptionReset’:
    thriftpy/transport/cybase.c:3187:22: error: ‘PyThreadState’ has no member named ‘exc_type’
         tmp_type = tstate->exc_type;
                          ^
    thriftpy/transport/cybase.c:3188:23: error: ‘PyThreadState’ has no member named ‘exc_value’
         tmp_value = tstate->exc_value;
                           ^
    thriftpy/transport/cybase.c:3189:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tmp_tb = tstate->exc_traceback;
                        ^
    thriftpy/transport/cybase.c:3190:11: error: ‘PyThreadState’ has no member named ‘exc_type’
         tstate->exc_type = type;
               ^
    thriftpy/transport/cybase.c:3191:11: error: ‘PyThreadState’ has no member named ‘exc_value’
         tstate->exc_value = value;
               ^
    thriftpy/transport/cybase.c:3192:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tstate->exc_traceback = tb;
               ^
    error: command 'gcc' failed with exit status 1

有是非常常见的 command 'gcc' failed with exit status 1 错误,但是却不是缺少Python.h,核心错误在于‘PyThreadState’ has no member named ‘xxxxxx’,于是在网上寻找和尝试了好久之后,终于解决,解决方法如下:

安装cython模块,命令行如下:

$ sudo pip install cython

安装成功之后,就可以继续安装happybase模块了

你可能感兴趣的:(Python)