cygdb ImportError: No module named 'Cython'

cygdb ImportError: No module named 'Cython'

我想调试我的 Cython 代码并按照 here 中描述的确切步骤进行操作。我的 Cython 代码编译($ cython --gdb xxx.pyx,然后 $ python setup.py build_ext --inplace)但似乎 cygdb 在我的系统上无法正常工作。我正在使用 Ubuntu 14.04、Python 2.7.6、Cython 0.23.4。我也在另一个系统 (Ubuntu 15.04) 上尝试过,但也没有成功。重新安装 Cython 也没有用。

$ python -c 'import Cython' 在我的系统上工作,我相信这表明 Cython 已正确安装。

我四处搜索但找不到解决方案。如有遗漏,请指出。

$ cygdb .

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Traceback (most recent call last):
  File "<string>", line 11, in <module>
ImportError: No module named 'Cython'
/tmp/tmpEkb_tX:19: Error in sourced command file:
Error while executing Python code.
(gdb) cy run abc.py
Undefined command: "cy".  Try "help".

问题是,正如@MarkPlotnick 所指出的,"Recent versions of Ubuntu have a gdb that uses Python3"。

要测试您的本地 gdb 使用的 Python 版本:

$ gdb
(gdb) python import sys; print(sys.version)

我以前说的是 3。4.x 这就是问题所在。

为了解决这个问题,我用 ./configure --with-python=python2 重新编译了我的 gdb。有关详细信息,请参阅 this

我不确定这是否是最佳解决方案,因为我是 Cython 和 cygdb 的新手。如果有请指出。