Rishi
Rishi

Reputation: 2037

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.

Upvotes: 5

Views: 7548

Answers (1)

NPE
NPE

Reputation: 500773

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

Upvotes: 20

Related Questions