简体   繁体   中英

cygdb ImportError: No module named 'Cython'

I want to debug my Cython code and followed the exact steps described here . My Cython code compiles ( $ cython --gdb xxx.pyx and then $ python setup.py build_ext --inplace ) but it seems that cygdb does not work properly on my system. I am using Ubuntu 14.04, Python 2.7.6, Cython 0.23.4. I've also tried it on another system (Ubuntu 15.04) but no luck either. Neither did re-installing Cython work.

$ python -c 'import Cython' works on my system, which, I believe, suggests that Cython is properly installed.

I googled around but couldn't find a solution. If there is anything I missed, please point out.

$ 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".

The problem is, as pointed out by @MarkPlotnick, "Recent versions of Ubuntu have a gdb that uses Python3".

To test which version of Python your local gdb uses:

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

Mine used to say 3.4.x and that's the problem.

To solve it, I re-compiled my gdb with ./configure --with-python=python2 . For further details, see this .

I'm not sure if this is the best solution as I'm new to Cython and cygdb. If there is, please point out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM