sbac
sbac

Reputation: 2081

How to solve the error when importing matplotlib in Anaconda on macOS?

I am using Python 3.6.5 in macOs 10.13.6 and I can not import matplotlib. I have uninstalled and reinstalled matplotlib with conda without results.

Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:44:09)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sergiobacelar/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py", line 127, in <module>
    from . import cbook
  File "/Users/sergiobacelar/anaconda3/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 2640, in <module>
    class _StringFuncParser(object):
  File "/Users/sergiobacelar/anaconda3/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 2652, in _StringFuncParser
    _funcs['quadratic'] = _FuncInfo(np.square,
AttributeError: module 'numpy' has no attribute 'square'

Upvotes: 0

Views: 256

Answers (1)

Adrien Mau
Adrien Mau

Reputation: 324

As mentioned by ImportanceOfBeingErnest it seems that matplotlib cannot import numpy, so try to uninstall and reinstall numpy with conda and tell us what you get. This seems to be a duplicate: How to fix AttributeError: module 'numpy' has no attribute 'square' Where your problem has been solved ;)

However it seems to me that when installing Anaconda, matplotlib and numpy are both preinstalled. Did you make change is these installations at some point ?

Upvotes: 1

Related Questions