5

I am new to stackoverflow as well as Python, and I hope to use stackoverflow to learn and improve my Python programming.

However, as soon as I set up Python, SciPy, NumPy on my Mac, I encountered a problem when I tried running a full test of SciPy and NumPy to verify the install:

>>> 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

As suggested by the error message, I install this 'nose' package via easy_install, and the install seems successful as I get the following from bash:

mlstr:~ mlstr$ nosetests -V
nosetests version 1.1.2

So I tried the SciPy test again, and it failed with the same message. Can someone please let me know if I need to do anything else to install/configure nose so that it can be used by the unit tests of SciPy and NumPy. Thanks in advance.

UPDATE #1: After trying Rahul's suggestion of using pip to reinstall nose, I think I've found where the problem is: whenever I do easy_install or pip from bash, the package is installed into Python 2.6 directories instead of 2.7 ones. And I think this is because by default 2.6 is the one shipped with Snow Leopard. So what should I do to tell easy_install or pip that I want to install a particular package for Python 2.7? Thanks.

UPDATE #2: By following up my update above, I've found the solution here: easy_install with various versions of python installed, mac osx. It is indeed because that I used the wrong version of easy_install thus my nose installation was for Python 2.6 shipped with Mac OS X. Thanks.

Community
  • 1
  • 1
MLister
  • 10,022
  • 18
  • 64
  • 92

2 Answers2

7

I tried replicating the error that you were encountering. I did not have nose, so I was getting the same error.

I installed nose using pip

sudo pip install nose

After that the scipy.test() worked. I did nothing else. Did you install nose using pip? If not, try using pip.

My machine has :
SciPy version 0.10.0.dev
Nose - 1.1.2

Rahul Arora
  • 1,036
  • 9
  • 8
  • I installed nose via easy_install, would that make any difference? Is there any way I can verify my nose installation? thanks. – MLister Nov 09 '11 at 11:11
  • @MLister To verify if you have *nose* installed `import nose` should not through an exception. – Woltan Nov 09 '11 at 13:14
0

If you want to use your locally installed python version you need to make sure, that this is called when you run python from console.

On a linux machine an alias would do that. Once you run the correct python from your console all the easy_install things will be available in the correct python version.

Woltan
  • 13,723
  • 15
  • 78
  • 104