Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install Matplotlib on macOS Big Sur

Since I've upgraded my MacOs to Big Sur I'm having some trouble with my data science libraries. I was able to install the numpy and pandas (even though it took an unusual amount of time as stated at this topic). But can't manage to install the Matplotlib.

I've tried three things... First with the default MacOs embedded Phyton 3.8.2 . Reinstalled numpy, upgraded pip, but when I've tried to install Matplotlib. I've got the following error:

    RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned

Later, I've seen some suggestions here at stackoverflow for similar problems, one suggested to use homebrew, so I've installed Python 3.9.0 through brew. However, when I've tried to install Matplotlib, still got a giant error, when it was trying to install Pillow:

(.......) The headers or library files could not be found for jpeg,a required dependency when compiling 
Pillow from source.Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/[email protected]/bin/python3.9 (...)

To finish (in almost despair) I've tried to create a virtual environment using venv (& Python 3.8.2) and was able to install NumPy successfully, however, I've got the following error trying to install Matplotlib:

(...... long line of code....) The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand.  Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.

Really don't know what to do... Is it impossible to use Matplotlib with a clean install on BigSur? hahaha =(

like image 506
digolira2 Avatar asked Nov 17 '20 22:11

digolira2


People also ask

Does matplotlib work on Mac?

If you are using Python from https://www.python.org, Homebrew, or Macports, then you can use the standard pip installer to install Matplotlib binaries in the form of wheels. ( sudo python3. 6 ... on Macports). You might also want to install IPython or the Jupyter notebook ( python3 -mpip install ipython notebook ).

Does pip work on m1 Mac?

Pip install doesn't work on m1 Mac.

How do you check matplotlib is installed or not?

To verify that Matplotlib is installed, try to invoke Matplotlib's version at the Python REPL. Use the commands below that include calling the . __version__ an attribute common to most Python packages.


2 Answers

I did it!!! I fix it!!

For this error :

  RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend.
 If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
 RankWarning: Polyfit may be poorly conditioned

I fixed installing an older numpy version.

pip3 install --force-reinstall numpy\<1.19

It did the job.

For the second error:

(.......) The headers or library files could not be found for jpeg,a required dependency when compiling 
Pillow from source.Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/[email protected]/bin/python3.9 (...)

It was the missing JPEG library. I do recommend you guys install homebrew. Solved this problem with:

brew install libjpeg
like image 179
digolira2 Avatar answered Oct 23 '22 22:10

digolira2


your easy_install is outdated.so just update your setup_tools by excuting following command:

pip install setuptools==51

then

easy_install --version

make sure your easy_install's version is above 51.

like image 1
user14798442 Avatar answered Oct 23 '22 20:10

user14798442