1

每次我尝试做任何涉及 kd-tree 的事情时,似乎都会出现以下错误。奇怪的是,就在几天前,这段代码运行良好,并且在我同事的机器上仍然运行良好(我们使用的是相同的存储库)。

无论我输入什么,它似乎都会发生。

任何人都可以提供任何见解吗?

  File "filename.py", line 69, in methodname
    get_index = self.kd_tree.query(array_to_query)
  File "/Library/Python/2.7/site-packages/scipy-0.12.0.dev_ddd617d_20120920-py2.7-macosx-10.8-x86_64.egg/scipy/spatial/kdtree.py", line 425, in query
    for c in np.ndindex(retshape):
  File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_9597b1f_20120920-py2.7-macosx-10.8-x86_64.egg/numpy/lib/index_tricks.py", line 536, in __init__
    x = as_strided(_nx.zeros(1), shape=shape, strides=_nx.zeros_like(shape))
  File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_9597b1f_20120920-py2.7-macosx-10.8-x86_64.egg/numpy/lib/stride_tricks.py", line 28, in as_strided
    return np.asarray(DummyArray(interface, base=x))
  File "/Library/Python/2.7/site-packages/numpy-1.8.0.dev_9597b1f_20120920-py2.7-macosx-10.8-x86_64.egg/numpy/core/numeric.py", line 320, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: negative dimensions are not allowed
4

1 回答 1

0

从来没有找到答案,但强制重新安装 numpy 和 scipy 解决了这个问题。

于 2013-01-24T22:32:50.967 回答