我怎样才能修复这个python解释器崩溃?

时间:2014-02-05 17:01:42

标签: python pandas scipy ipython

我正在使用PANDAS运行一个小脚本,我得到了一个相当令人印象深刻的解释器错误。在这个问题的最后,我已经包含了完整的堆栈跟踪,因为它太长了。

使用ipdb,我设法隔离了可能位于错误原点的块。在断点之间执行代码时,以下代码块将以更简洁的错误消息“ipython” terminated by signal SIGSEGV (Address boundary error)退出:

samples = pd.DataFrame(
    re.findall(re_samp, m), columns=('t', 'x', 'y', 'cr')
)

import ipdb; ipdb.set_trace()
# set nans when eyes are not being tracked
for c in samples:
    samples[c][samples[c] == '.'] = pd.np.nan

    # column type conversions
    if c == 't':
        samples[c] = samples[c].astype(int)
    else:
        samples[c] = samples[c].astype(float)
ipdb.set_trace()

在上面的代码段中,两个ipdb语句之间出现错误,特别是此行:samples[c][samples[c] == '.'] = pd.np.nan

除了涉及PANDAS和scipy稀疏矩阵这一事实之外( c.f。追踪回溯),我绝对不知道:

  1. 问题是什么
  2. 我应该如何解决它
  3. 非常欢迎任何建议!非常感谢你提前!

    *** Error in `/usr/bin/python': free(): invalid size: 0x0000000003712f30 ***
    ======= Backtrace: =========
    /lib/x86_64-linux-gnu/libc.so.6(+0x80996)[0x7f3e69f98996]
    /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so(+0x86b77)[0x7f3e6599eb77]
    /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so(+0x9e99d)[0x7f3e659b699d]
    /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so(+0x9e95c)[0x7f3e659b695c]
    /usr/bin/python[0x484b53]
    /usr/bin/python[0x559f7f]
    /usr/bin/python[0x484b53]
    /usr/bin/python[0x55988f]
    /usr/bin/python[0x484736]
    /usr/bin/python[0x55988f]
    /usr/bin/python[0x55976f]
    /usr/bin/python[0x484736]
    /usr/bin/python[0x55aa43]
    /usr/bin/python[0x558d90]
    /usr/bin/python[0x558ea0]
    /usr/bin/python(PyDict_SetItem+0x566)[0x526ec6]
    /usr/bin/python(PyDict_SetItemString+0x10d)[0x501aed]
    /usr/bin/python(PyEval_EvalFrameEx+0x354d)[0x530f1d]
    /usr/bin/python(PyEval_EvalFrameEx+0xca2)[0x52e672]
    /usr/bin/python(PyEval_EvalCode+0xfc)[0x567cdc]
    /usr/bin/python(PyEval_EvalFrameEx+0x59eb)[0x5333bb]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x1a22)[0x52f3f2]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x867)[0x52e237]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x867)[0x52e237]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x867)[0x52e237]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x867)[0x52e237]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x1a22)[0x52f3f2]
    /usr/bin/python(PyEval_EvalCodeEx+0x2a4)[0x505b24]
    /usr/bin/python(PyEval_EvalFrameEx+0x1a22)[0x52f3f2]
    /usr/bin/python(PyEval_EvalCode+0xfc)[0x567cdc]
    /usr/bin/python[0x451adb]
    /usr/bin/python(PyRun_FileExFlags+0x92)[0x451e5b]
    /usr/bin/python(PyRun_SimpleFileExFlags+0x2ee)[0x452394]
    /usr/bin/python(Py_Main+0xb5e)[0x453ead]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f3e69f39de5]
    /usr/bin/python[0x5786be]
    ======= Memory map: ========
    00400000-006ba000 r-xp 00000000 08:06 2491349                            /usr/bin/python2.7
    008b9000-008ba000 r--p 002b9000 08:06 2491349                            /usr/bin/python2.7
    008ba000-0092f000 rw-p 002ba000 08:06 2491349                            /usr/bin/python2.7
    0092f000-00941000 rw-p 00000000 00:00 0 
    01499000-09020000 rw-p 00000000 00:00 0                                  [heap]
    7f3e53a58000-7f3e54386000 rw-p 00000000 00:00 0 
    7f3e54fb8000-7f3e558d0000 rw-p 00000000 00:00 0 
    7f3e558d0000-7f3e558d5000 r-xp 00000000 08:06 2626378                    /usr/lib/python2.7/lib-dynload/mmap.x86_64-linux-gnu.so
    7f3e558d5000-7f3e55ad4000 ---p 00005000 08:06 2626378                    /usr/lib/python2.7/lib-dynload/mmap.x86_64-linux-gnu.so
    7f3e55ad4000-7f3e55ad5000 r--p 00004000 08:06 2626378                    /usr/lib/python2.7/lib-dynload/mmap.x86_64-linux-gnu.so
    7f3e55ad5000-7f3e55ad6000 rw-p 00005000 08:06 2626378                    /usr/lib/python2.7/lib-dynload/mmap.x86_64-linux-gnu.so
    7f3e55ad8000-7f3e55ae2000 r-xp 00000000 08:06 5247160                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/streams.so
    7f3e55ae2000-7f3e55ce1000 ---p 0000a000 08:06 5247160                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/streams.so
    7f3e55ce1000-7f3e55ce2000 r--p 00009000 08:06 5247160                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/streams.so
    7f3e55ce2000-7f3e55ce3000 rw-p 0000a000 08:06 5247160                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/streams.so
    7f3e55ce3000-7f3e55ce4000 rw-p 00000000 00:00 0 
    7f3e55ce8000-7f3e55d06000 r-xp 00000000 08:06 5247162                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5_utils.so
    7f3e55d06000-7f3e55f06000 ---p 0001e000 08:06 5247162                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5_utils.so
    7f3e55f06000-7f3e55f07000 r--p 0001e000 08:06 5247162                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5_utils.so
    7f3e55f07000-7f3e55f0b000 rw-p 0001f000 08:06 5247162                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio5_utils.so
    7f3e55f10000-7f3e55f16000 r-xp 00000000 08:06 5247159                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio_utils.so
    7f3e55f16000-7f3e56115000 ---p 00006000 08:06 5247159                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio_utils.so
    7f3e56115000-7f3e56116000 r--p 00005000 08:06 5247159                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio_utils.so
    7f3e56116000-7f3e56117000 rw-p 00006000 08:06 5247159                    /usr/lib/python2.7/dist-packages/scipy/io/matlab/mio_utils.so
    7f3e56118000-7f3e56125000 r-xp 00000000 08:06 5247240                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_min_spanning_tree.so
    7f3e56125000-7f3e56324000 ---p 0000d000 08:06 5247240                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_min_spanning_tree.so
    7f3e56324000-7f3e56325000 r--p 0000c000 08:06 5247240                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_min_spanning_tree.so
    7f3e56325000-7f3e56328000 rw-p 0000d000 08:06 5247240                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_min_spanning_tree.so
    7f3e56328000-7f3e56341000 r-xp 00000000 08:06 5247242                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_traversal.so
    7f3e56341000-7f3e56540000 ---p 00019000 08:06 5247242                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_traversal.so
    7f3e56540000-7f3e56541000 r--p 00018000 08:06 5247242                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_traversal.so
    7f3e56541000-7f3e56546000 rw-p 00019000 08:06 5247242                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_traversal.so
    7f3e56546000-7f3e56547000 rw-p 00000000 00:00 0 
    7f3e56548000-7f3e56560000 r-xp 00000000 08:06 5247239                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_tools.so
    7f3e56560000-7f3e5675f000 ---p 00018000 08:06 5247239                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_tools.so
    7f3e5675f000-7f3e56760000 r--p 00017000 08:06 5247239                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_tools.so
    7f3e56760000-7f3e56765000 rw-p 00018000 08:06 5247239                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_tools.so
    7f3e56768000-7f3e56791000 r-xp 00000000 08:06 5247241                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_shortest_path.so
    7f3e56791000-7f3e56991000 ---p 00029000 08:06 5247241                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_shortest_path.so
    7f3e56991000-7f3e56992000 r--p 00029000 08:06 5247241                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_shortest_path.so
    7f3e56992000-7f3e56998000 rw-p 0002a000 08:06 5247241                    /usr/lib/python2.7/dist-packages/scipy/sparse/csgraph/_shortest_path.so
    7f3e56998000-7f3e5699e000 r-xp 00000000 08:06 5247214                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csgraph.so
    7f3e5699e000-7f3e56b9d000 ---p 00006000 08:06 5247214                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csgraph.so
    7f3e56b9d000-7f3e56b9e000 r--p 00005000 08:06 5247214                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csgraph.so
    7f3e56b9e000-7f3e56b9f000 rw-p 00006000 08:06 5247214                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csgraph.so
    7f3e56ba0000-7f3e56c8f000 r-xp 00000000 08:06 5247213                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_bsr.so
    7f3e56c8f000-7f3e56e8e000 ---p 000ef000 08:06 5247213                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_bsr.so
    7f3e56e8e000-7f3e56e8f000 r--p 000ee000 08:06 5247213                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_bsr.so
    7f3e56e8f000-7f3e56e90000 rw-p 000ef000 08:06 5247213                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_bsr.so
    7f3e56e90000-7f3e56e9d000 r-xp 00000000 08:06 5247217                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_dia.so
    7f3e56e9d000-7f3e5709d000 ---p 0000d000 08:06 5247217                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_dia.so
    7f3e5709d000-7f3e5709e000 r--p 0000d000 08:06 5247217                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_dia.so
    7f3e5709e000-7f3e5709f000 rw-p 0000e000 08:06 5247217                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_dia.so
    7f3e570a0000-7f3e570c6000 r-xp 00000000 08:06 5247215                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_coo.so
    7f3e570c6000-7f3e572c5000 ---p 00026000 08:06 5247215                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_coo.so
    7f3e572c5000-7f3e572c6000 r--p 00025000 08:06 5247215                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_coo.so
    7f3e572c6000-7f3e572c7000 rw-p 00026000 08:06 5247215                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_coo.so
    7f3e572c8000-7f3e57348000 r-xp 00000000 08:06 5247218                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csc.so
    7f3e57348000-7f3e57547000 ---p 00080000 08:06 5247218                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csc.so
    7f3e57547000-7f3e57548000 r--p 0007f000 08:06 5247218                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csc.so
    7f3e57548000-7f3e57549000 rw-p 00080000 08:06 5247218                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csc.so
    7f3e57550000-7f3e57621000 r-xp 00000000 08:06 5247216                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csr.so
    7f3e57621000-7f3e57820000 ---p 000d1000 08:06 5247216                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csr.so
    7f3e57820000-7f3e57821000 r--p 000d0000 08:06 5247216                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csr.so
    7f3e57821000-7f3e57823000 rw-p 000d1000 08:06 5247216                    /usr/lib/python2.7/dist-packages/scipy/sparse/sparsetools/_csr.so
    7f3e57828000-7f3e57833000 r-xp 00000000 08:06 2498783                    /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
    7f3e57833000-7f3e57a32000 ---p 0000b000 08:06 2498783                    /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
    7f3e57a32000-7f3e57a33000 r--p 0000a000 08:06 2498783                    /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
    7f3e57a33000-7f3e57a36000 rw-p 0000b000 08:06 2498783                    /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
    7f3e57a38000-7f3e57aa6000 r-xp 00000000 08:06 2499073                    /usr/lib/x86_64-linux-gnu/libtiff.so.5.1.0
    7f3e57aa6000-7f3e57ca6000 ---p 0006e000 08:06 2499073                    /usr/lib/x86_64-linux-gnu/libtiff.so.5.1.0
    7f3e57ca6000-7f3e57ca7000 r--p 0006e000 08:06 2499073                    /usr/lib/x86_64-linux-gnu/libtiff.so.5.1.0
    7f3e57ca7000-7f3e57caa000 rw-p 0006f000 08:06 2499073                    /usr/lib/x86_64-linux-gnu/libtiff.so.5.1.0
    7f3e57cb0000-7f3e57cf3000 r-xp 00000000 08:06 2496034                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
    7f3e57cf3000-7f3e57ef3000 ---p 00043000 08:06 2496034                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
    7f3e57ef3000-7f3e57ef4000 r--p 00043000 08:06 2496034                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
    7f3e57ef4000-7f3e57ef5000 rw-p 00044000 08:06 2496034                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
    7f3e57ef5000-7f3e57f05000 rw-p 00000000 00:00 0 
    7f3e57f08000-7f3e57f49000 r-xp 00000000 08:06 2624064                    /usr/lib/python2.7/dist-packages/_imaging.so
    7f3e57f49000-7f3e58148000 ---p 00041000 08:06 2624064                    /usr/lib/python2.7/dist-packages/_imaging.so
    7f3e58148000-7f3e5814b000 r--p 00040000 08:06 2624064                    /usr/lib/python2.7/dist-packages/_imaging.so
    7f3e5814b000-7f3e5814e000 rw-p 00043000 08:06 2624064                    /usr/lib/python2.7/dist-packages/_imaging.so
    7f3e58150000-7f3e58167000 r-xp 00000000 08:06 4337590                    /usr/lib/python2.7/dist-packages/pandas/msgpack.so
    7f3e58167000-7f3e58366000 ---p 00017000 08:06 4337590                    /usr/lib/python2.7/dist-packages/pandas/msgpack.so
    7f3e58366000-7f3e58367000 r--p 00016000 08:06 4337590                    /usr/lib/python2.7/dist-packages/pandas/msgpack.so
    7f3e58367000-7f3e5836b000 rw-p 00017000 08:06 4337590                    /usr/lib/python2.7/dist-packages/pandas/msgpack.so
    7f3e58370000-7f3e58374000 r-xp 00000000 08:06 1445743                    /lib/x86_64-linux-gnu/libgpg-error.so.0.10.0
    7f3e58374000-7f3e58573000 ---p 00004000 08:06 1445743                    /lib/x86_64-linux-gnu/libgpg-error.so.0.10.0
    7f3e58573000-7f3e58574000 r--p 00003000 08:06 1445743                    /lib/x86_64-linux-gnu/libgpg-error.so.0.10.0
    7f3e58574000-7f3e58575000 rw-p 00004000 08:06 1445743                    /lib/x86_64-linux-gnu/libgpg-error.so.0.10.0
    7f3e58578000-7f3e58599000 r-xp 00000000 08:06 1445760                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
    7f3e58599000-7f3e58798000 ---p 00021000 08:06 1445760                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
    7f3e58798000-7f3e58799000 r--p 00020000 08:06 1445760                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
    7f3e58799000-7f3e5879a000 rw-p 00021000 08:06 1445760                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
    7f3e587a0000-7f3e5881a000 r-xp 00000000 08:06 1445739                    /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
    7f3e5881a000-7f3e58a1a000 ---p 0007a000 08:06 1445739                    /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
    7f3e58a1a000-7f3e58a1b000 r--p 0007a000 08:06 1445739                    /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
    7f3e58a1b000-7f3e58a1e000 rw-p 0007b000 08:06 1445739                    /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
    

1 个答案:

答案 0 :(得分:3)

看到红色的大胆警告:

http://pandas.pydata.org/pandas-docs/dev/whatsnew.html#v0-13-1-february-3-2014

这是一个很小的互动< 1.8在执行chained assignment

时,请参阅pandas 0.13.0

按照以下方式完成作业:

samples.loc[samples[c]=='.',c] = np.nan