我想调试我的 Cython 代码并按照描述的确切步骤进行操作here http://docs.cython.org/src/userguide/debugging.html。我的 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 所指出的,问题是“最新版本的 Ubuntu 有一个使用 Python3 的 gdb”。
要测试本地 gdb 使用哪个版本的 Python:
$ gdb
(gdb) python import sys; print(sys.version)
我的以前说的是 3.4.x,这就是问题所在。
为了解决这个问题,我重新编译了 gdb./configure --with-python=python2
。有关更多详细信息,请参阅this https://gist.github.com/zachriggle/2afe40af1416af68d1e5.
我不确定这是否是最好的解决方案,因为我是 Cython 和 cygdb 的新手。如果有请指出。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)