Python3.7 mlpy 安装错误 - 'PyThreadState aka struct _ts' 没有名为 'exc_type' 的成员

Posted

技术标签:

【中文标题】Python3.7 mlpy 安装错误 - \'PyThreadState aka struct _ts\' 没有名为 \'exc_type\' 的成员【英文标题】:Python3.7 mlpy installation error - 'PyThreadState aka struct _ts' has no member named 'exc_type'Python3.7 mlpy 安装错误 - 'PyThreadState aka struct _ts' 没有名为 'exc_type' 的成员 【发布时间】:2020-04-23 08:34:30 【问题描述】:

尝试在 macOS Catalina 的虚拟环境中安装 mlpy 3.5.0,但出现错误。

In file included from /Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:0,
                 from /Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                 from /Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from mlpy/gsl/gsl.c:227:
/Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it with " \
  ^
mlpy/gsl/gsl.c: In function '__pyx_pf_4mlpy_3gsl_2stats_quantile_from_sorted_data':
mlpy/gsl/gsl.c:921:14: warning: variable '__pyx_bshape_0_sorted_data_arr' set but not used [-Wunused-but-set-variable]
   Py_ssize_t __pyx_bshape_0_sorted_data_arr = 0;
              ^
mlpy/gsl/gsl.c:920:14: warning: variable '__pyx_bstride_0_sorted_data_arr' set but not used [-Wunused-but-set-variable]
   Py_ssize_t __pyx_bstride_0_sorted_data_arr = 0;
              ^
mlpy/gsl/gsl.c: In function '__Pyx_GetException':
mlpy/gsl/gsl.c:4027:22: error: 'PyThreadState aka struct _ts' has no member named 'exc_type'
     tmp_type = tstate->exc_type;
                      ^
mlpy/gsl/gsl.c:4028:23: error: 'PyThreadState aka struct _ts' has no member named 'exc_value'
     tmp_value = tstate->exc_value;
                       ^
mlpy/gsl/gsl.c:4029:20: error: 'PyThreadState aka struct _ts' has no member named 'exc_traceback'
     tmp_tb = tstate->exc_traceback;
                    ^
mlpy/gsl/gsl.c:4030:11: error: 'PyThreadState aka struct _ts' has no member named 'exc_type'
     tstate->exc_type = local_type;
           ^
mlpy/gsl/gsl.c:4031:11: error: 'PyThreadState aka struct _ts' has no member named 'exc_value'
     tstate->exc_value = local_value;
           ^
mlpy/gsl/gsl.c:4032:11: error: 'PyThreadState aka struct _ts' has no member named 'exc_traceback'
     tstate->exc_traceback = local_tb;
           ^
mlpy/gsl/gsl.c: In function '__Pyx_ExceptionSave':
mlpy/gsl/gsl.c:4222:19: error: 'PyThreadState aka struct _ts' has no member named 'exc_type'
     *type = tstate->exc_type;
                   ^
mlpy/gsl/gsl.c:4223:20: error: 'PyThreadState aka struct _ts' has no member named 'exc_value'
     *value = tstate->exc_value;
                    ^
mlpy/gsl/gsl.c:4224:17: error: 'PyThreadState aka struct _ts' has no member named 'exc_traceback'
     *tb = tstate->exc_traceback;
                 ^
mlpy/gsl/gsl.c: In function '__Pyx_ExceptionReset':
mlpy/gsl/gsl.c:4233:22: error: 'PyThreadState aka struct _ts' has no member named 'exc_type'
     tmp_type = tstate->exc_type;
                      ^
mlpy/gsl/gsl.c:4234:23: error: 'PyThreadState aka struct _ts' has no member named 'exc_value'
     tmp_value = tstate->exc_value;
                       ^
mlpy/gsl/gsl.c:4235:20: error: 'PyThreadState aka struct _ts' has no member named 'exc_traceback'
     tmp_tb = tstate->exc_traceback;
                    ^
mlpy/gsl/gsl.c:4236:11: error: 'PyThreadState aka struct _ts' has no member named 'exc_type'
     tstate->exc_type = type;
           ^
mlpy/gsl/gsl.c:4237:11: error: 'PyThreadState aka struct _ts' has no member named 'exc_value'
     tstate->exc_value = value;
           ^
mlpy/gsl/gsl.c:4238:11: error: 'PyThreadState aka struct _ts' has no member named 'exc_traceback'
     tstate->exc_traceback = tb;
           ^
In file included from /Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:21:0,
                 from /Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from mlpy/gsl/gsl.c:227:
mlpy/gsl/gsl.c: At top level:
/Users/martin/.virtualenvs/BA/lib/python3.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1463:1 warning: '_import_array' defined but not used [-Wunused-function]
 _import_array(void)
 ^
error: command 'gcc-5' failed with exit status 1 

我猜该解决方案与this answer 有关,但由于我不习惯 C++ 语法,我无法让它工作。我需要在哪里插入

    #define exc_type       exc_state.exc_type
    #define exc_value      exc_state.exc_value
    #define exc_traceback  exc_state.exc_traceback 

在文件 /usr/include/python3.7m/pystate.h 中还是在我的虚拟环境中的文件中?

【问题讨论】:

我猜你需要安装 cython 并重新运行安装。没有 cython 的后备 c 文件是使用不适合 python 3.7 的 cython 版本创建的 我已经使用 pip 安装了 Cython,但仍然收到相同的错误消息。是否会自动检测 Cython? cython是否安装在同一个虚拟环境中?应该是的。 【参考方案1】:

通过删除由 Cython 创建并已包含在存档中的 mlpy 的所有子文件夹中的所有 .c 文件来解决。

【讨论】:

以上是关于Python3.7 mlpy 安装错误 - 'PyThreadState aka struct _ts' 没有名为 'exc_type' 的成员的主要内容,如果未能解决你的问题,请参考以下文章

安装mlpy时出现gsl错误[关闭]

mac下python3.7安装mysqlclient出错解决

python pip安装使用wheel文件无法正常工作

mac环境 python3.7 lzma.py 报错解决

python3.7.3使用web.py报错解决办法 and RuntimeError: generator raised StopIteration

Python3.7安装Geenlet