我是stackoverflow和Python的新手,我希望使用stackoverflow来学习和改进我的Python编程。
然而,只要我在Mac上设置Python,SciPy,NumPy,我在尝试运行SciPy和NumPy的完整测试以验证安装时遇到了问题:
>>> import scipy
>>> scipy.test()
Running unit tests for scipy
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
scipy.test()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/nosetester.py", line 318, in test
self._show_system_info()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/nosetester.py", line 187, in _show_system_info
nose = import_nose()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/nosetester.py", line 69, in import_nose
raise ImportError(msg)
ImportError: Need nose >= 0.10.0 for tests - see http://somethingaboutorange.com/mrl/projects/nose
正如错误消息所示,我通过easy_install安装了这个'nose'软件包,安装似乎很成功,因为我从bash获得以下内容:
mlstr:~ mlstr$ nosetests -V
nosetests version 1.1.2
所以我再次尝试了SciPy测试,它失败了同样的消息。有人可以告诉我是否需要做任何其他事情来安装/配置鼻子,以便它可以被SciPy和NumPy的单元测试使用。提前谢谢。
UPDATE#1 :在尝试了Rahul建议使用pip重新安装鼻子之后,我想我已经找到了问题所在:每当我从bash进行easy_install或pip时,都会将软件包安装到Python 2.6目录而不是2.7目录。而且我认为这是因为默认情况下2.6是Snow Leopard附带的。那么我该怎么做才能告诉easy_install或pip我想为Python 2.7安装一个特定的包?感谢。
更新#2 :通过跟进上述更新,我在此处找到了解决方案:easy_install with various versions of python installed, mac osx。确实是因为我使用了错误版本的easy_install,因此我的鼻子安装适用于Mac OS X附带的Python 2.6。谢谢。
答案 0 :(得分:7)
我尝试复制您遇到的错误。我没有鼻子,所以我得到了同样的错误。
我用pip安装了鼻子
sudo pip install nose
之后scipy.test()起作用了。我什么也没做。你用pip装鼻子了吗?如果没有,请尝试使用pip。
我的机器有:
SciPy版本0.10.0.dev
鼻子 - 1.1.2
答案 1 :(得分:0)
如果你想使用本地安装的python版本,你需要确保从控制台运行python时调用它。
在linux机器上,别名会这样做。从控制台运行正确的python之后,所有easy_install都将以正确的python版本提供。