1. 程式人生 > >Python安裝第三方庫,出現‘PyThreadState’ has no member named ‘exc_type’解決方法

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模組了