linux上cython编译错误

在Linux上cython编译遇到问题:

python setup.py build_ext --inplace

问题如下:
running build_ext
skipping ‘bbox.c’ Cython extension (up-to-date)
skipping ‘nms.c’ Cython extension (up-to-date)
building ‘cython_bbox’ extension
{‘gcc’: [’-Wno-cpp’, ‘-Wno-unused-function’]}
gcc -pthread -B /home/gsadhasivam/anaconda3/envs/r3det/compiler_compat -Wl,–sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/gsadhasivam/anaconda3/envs/r3det/lib/python3.7/site-packages/numpy/core/include -I/home/gsadhasivam/anaconda3/envs/r3det/include/python3.7m -c bbox.c -o build/temp.linux-x86_64-3.7/bbox.o -Wno-cpp -Wno-unused-function
bbox.c: In function ‘__Pyx__ExceptionSave’:
bbox.c:9439:19: error: ‘PyThreadState’ has no member named ‘exc_type’
*type = tstate->exc_type;
^
bbox.c:9440:20: error: ‘PyThreadState’ has no member named ‘exc_value’
*value = tstate->exc_value;
^
bbox.c:9441:17: error: ‘PyThreadState’ has no member named ‘exc_traceback’
*tb = tstate->exc_traceback;
^
bbox.c: In function ‘__Pyx__ExceptionReset’:
bbox.c:9448:22: error: ‘PyThreadState’ has no member named ‘exc_type’
tmp_type = tstate->exc_type;
^
bbox.c:9449:23: error: ‘PyThreadState’ has no member named ‘exc_value’
tmp_value = tstate->exc_value;
^
bbox.c:9450:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
tmp_tb = tstate->exc_traceback;
^
bbox.c:9451:11: error: ‘PyThreadState’ has no member named ‘exc_type’
tstate->exc_type = type;
^
bbox.c:9452:11: error: ‘PyThreadState’ has no member named ‘exc_value’
tstate->exc_value = value;
^
bbox.c:9453:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
tstate->exc_traceback = tb;
^
bbox.c: In function ‘__Pyx__GetException’:
bbox.c:9508:22: error: ‘PyThreadState’ has no member named ‘exc_type’
tmp_type = tstate->exc_type;
^
bbox.c:9509:23: error: ‘PyThreadState’ has no member named ‘exc_value’
tmp_value = tstate->exc_value;
^
bbox.c:9510:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
tmp_tb = tstate->exc_traceback;
^
bbox.c:9511:11: error: ‘PyThreadState’ has no member named ‘exc_type’
tstate->exc_type = local_type;
^
bbox.c:9512:11: error: ‘PyThreadState’ has no member named ‘exc_value’
tstate->exc_value = local_value;
^
bbox.c:9513:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
tstate->exc_traceback = local_tb;
^
error: command ‘gcc’ failed with exit status 1
首先,发现python是3.7,所以需要将python版本换为3.5即可
可通过如下来创建一个conda虚拟环境

conda create -n conda-env python=3.5
conda activate conda-env
conda install -c anaconda cudatoolkit=10.0
conda install cudnn
pip install numpy1.16.4
pip install tensorflow_gpu
1.13.1
pip install cython
pip install pillow
pip install opencv-python

然后再编译就可以了。

你可能感兴趣的:(linux上cython编译错误)