Ask Your Question
0

Error when importing Numpy

asked 2019-10-11 15:35:14 +0200

EulerIsAPimp gravatar image

I'm running the most recent version of Sage via the terminal in OS 10.14.6. When importing numpy I get the following error,

sage: import numpy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-d4cdadb62aa7> in <module>()
----> 1 import numpy

/Applications/SageMath/local/lib/python2.7/site-packages/numpy/__init__.py in <module>()
    140     from . import _distributor_init
    141 
--> 142     from . import core
    143     from .core import *
    144     from . import compat

/Applications/SageMath/local/lib/python2.7/site-packages/numpy/core/__init__.py in <module>()
     65         "numpy in {}. One method of fixing this is to repeatedly uninstall "
     66         "numpy until none is found, then reinstall this version.")
---> 67     raise ImportError(msg.format(path))
     68 
     69 from . import numerictypes as nt

ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/Applications/SageMath/local/lib/python2.7/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

I've tried repeatedly uninstalling as suggested using pip. However, this did not resolve the issue. The pip uninstall didn't seem to touch the numpy installation mentioned in the error.

edit retag flag offensive close merge delete

Comments

My numpy is located similarly:

sage: import numpy
sage: numpy
<module 'numpy' from '/usr/lib/python2.7/site-packages/numpy/__init__.pyc'>

Please look inside the core folder, where the error appears. I see the following lines:

if not (hasattr(multiarray, '_multiarray_umath') and
        hasattr(umath, '_multiarray_umath')):
    import sys
    path = sys.modules['numpy'].__path__
    msg = ("Something is wrong with the numpy installation. "
        "While importing we detected an older version of "
        "numpy in {}. One method of fixing this is to repeatedly uninstall "
        "numpy until none ...

(Code truncated.) Some lines before there are some hints what to do in your case.

dan_fulea gravatar imagedan_fulea ( 2019-10-16 12:56:05 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-30 03:00:00 +0200

slelievre gravatar image

When uninstalling with pip, make sure to use SageMath's pip:

sage --pip uninstall numpy
edit flag offensive delete link more

Comments

They should not be doing anything with pip related to numpy in Sage. The Numpy package is an "spkg" managed by Sage's build system, and should not be messed around with using pip. It's hard to say what the real problem here is, but I suspect something to do with the user's environment; PYTHONPATH or something related.

Iguananaut gravatar imageIguananaut ( 2019-11-05 15:04:18 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-10-11 15:35:14 +0200

Seen: 1,807 times

Last updated: Oct 30 '19