Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Cython code in Pandas?

I have downloaded Pandas source and now trying to debug it. I modified Makefile:

sparse: pandas/src/sparse.pyx
python-dbg setup.py build_ext --inplace --pyrex-gdb

build: clean_pyc
python-dbg setup.py build_ext --inplace --pyrex-gdb

develop: build
-python-dbg setup.py develop --pyrex-gdb

Also I have a very simple script:

from numpy import asarray
from pandas import algos

v = [4171.0, 0.0]
expAverage = algos.ewma(asarray(v), 50, 1)

print expAverage

When I try to run it with python-dbg test1.py, this is what I get:

/tmp/1/pandas/pandas/hashtable.so: undefined symbol: Py_InitModule4_64
Traceback (most recent call last):
  File "test1.py", line 2, in <module>
    from pandas import algos
  File "/tmp/1/pandas/pandas/__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
ImportError: /tmp/1/pandas/pandas/hashtable.so: undefined symbol: Py_InitModule4_64
[94423 refs]

What is wrong?

like image 514
relgames Avatar asked Dec 13 '13 13:12

relgames


1 Answers

  1. Obviously, at least one of your (C) extensions that is being loaded has not been compiled with debug info in a way that python-dbg can use.

This explanation has the details:

http://hustoknow.blogspot.co.uk/2013/06/why-your-python-program-cant-start-when.html

To me it seems like --with-pydebug flag is not equivalent / triggers the same actions as --pyrex-gdb. BTW, it seems that --pyrex-gdb has been renamed to --cython-gdb.

  1. Can you use cygdb or cython --gdb instead? It seems like the flag that you're using has been reported not to work: https://groups.google.com/forum/#!topic/cython-users/K6sjhzUX5JA
like image 185
LetMeSOThat4U Avatar answered Sep 17 '22 23:09

LetMeSOThat4U