Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numpy: ImportError: cannot import name TestCase

I installed numpy from

sudo apt-get install numpy

Then in python2.7 on importing numpy with

import numpy

I get this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 45, in <module>
    from numpy.testing import Tester
  File "/usr/local/lib/python2.7/dist-packages/numpy/testing/__init__.py", line 8, in <module>
    from unittest import TestCase
ImportError: cannot import name TestCase

I then removed Numpy and Scipy. Then again installed from the github repo. But I still get the same error. Please help.

Thank You.

like image 274
Rishi Avatar asked Jun 06 '12 15:06

Rishi


1 Answers

I suspect that you have a local file called unittest.py that is getting imported instead of the standard module.

like image 144
NPE Avatar answered Oct 08 '22 02:10

NPE