当我尝试运行nosetests时,许多python的模块错误

时间:2014-06-20 13:06:13

标签: python macos unit-testing numpy nosetests

为什么当我运行nosetests时,我会陷入有关python模块的几个错误中:

...
    output = np.polynomial.legendre.leggauss(deg)
AttributeError: 'module' object has no attribute 'leggauss'

----------------------------------------------------------------------
Ran 1 test in 0.954s

FAILED (errors=1)

我不确定是否存在依赖性问题,或者在运行nosetests之前我错过了一些设置步骤。

但无论如何,当我运行我的主程序时,我确实没有问题,它运作良好。但对于我的测试文件,它出错了。

Addtional:实际上,对于numpy,在output = np.polynomial.legendre.leggauss(deg)行之前有3行调用numpy

  8 A = np.zeros(shape=(deg, deg), dtype=np.complex)
  9 R = np.zeros(shape=(deg), dtype=np.complex)
 10 J = np.zeros(shape=(deg))
 11 output = np.polynomial.legendre.leggauss(deg)

但是对于第8,9,10行,没有任何错误,但第11行发生了错误。

1 个答案:

答案 0 :(得分:1)

好的,一切都很好。我只是忘了出口路径。

export PYTHONPATH=/Library/Python/2.7/site-packages:/opt/local/lib/python2.7

把它放在〜/ .profile