pip install kenlm 报错 ‘PyThreadState‘ {aka ‘struct _ts’} has no member named ‘exc_type’

Debian 上面 pip 安装 kenlm 的报错 PyThreadState 的成员找不到, 错误信息如下。

python/kenlm.cpp:6379:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
       6379 |     tstate->exc_type = *type;
            |             ^~~~~~~~
            |             curexc_type
      python/kenlm.cpp:6380:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
       6380 |     tstate->exc_value = *value;

环境: debian 11, Python 3.10

因为 cython 版本比较老导致的问题。

解决方案有两个,

1.安装 pypi-kenlm

pip install pypi-kenlm

2.从源代码安装 kenlm

扫描二维码关注公众号,回复: 14591706 查看本文章
  1. git clone GitHub - kpu/kenlm: KenLM: Faster and Smaller Language Model Queries
  2. cd kenlm/python
  3. cython -3 --cplus kenlm.pyx
  4. pip install -e .

猜你喜欢

转载自blog.csdn.net/davidullua/article/details/126696471