I'm unable to install matplotlib through pip on my M1 Mac. I have Python 3.9.1 installed through Homebrew. I've tried the solution here: Pip install matplotlib fails on M1 Mac but it does not work for me.
I get this long error:
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): no suitable image found. Did find:
/opt/homebrew/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so: mach-o, but wrong architecture
/opt/homebrew/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so: mach-o, but wrong architecture
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setup.py", line 256, in <module>
setup( # Finally, pass this all along to distutils to do the heavy lifting.
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 299, in run
self.find_sources()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 306, in find_sources
mm.run()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 541, in run
self.add_defaults()
File "/opt/homebrew/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 577, in add_defaults
sdist.add_defaults(self)
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/sdist.py", line 228, in add_defaults
self._add_defaults_ext()
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/command/sdist.py", line 311, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 299, in get_finalized_command
cmd_obj.ensure_finalized()
File "/opt/homebrew/Cellar/python#3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setup.py", line 88, in finalize_options
self.distribution.ext_modules[:] = [
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setup.py", line 91, in <listcomp>
for ext in package.get_extensions()
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setupext.py", line 345, in get_extensions
add_numpy_flags(ext)
File "/private/tmp/pip-install-mrz7uc56/matplotlib_20151701613b4e6fb6955488fa89e81e/setupext.py", line 468, in add_numpy_flags
import numpy as np
File "/opt/homebrew/lib/python3.9/site-packages/numpy/__init__.py", line 145, in <module>
from . import core
File "/opt/homebrew/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
I am able to import matplotlib with python 2.7 on my Rosetta Terminal but I am trying to use matplotlib with python3 instead.
Any help would be appreciated!
November 2021 Update
Just run the following command:
$ pip3 install matplotlib
Worked on Mac mini (M1, 2020), Monterey 12.0.1. Python 3.9.7
Feb 2021 Answer Below
In order to install matplotlib with pip3 on an M1 mac, you first need to install the dependencies Cython, numpy and Pillow from source. The following method worked for me.
Install Cython
pip3 install Cython
Install numpy
$ git clone https://github.com/numpy/numpy.git
$ cd numpy
$ pip3 install . --no-binary :all: --no-use-pep517
Install Pillow
libjpeg is necessary for Pillow so you might want to install it via brew.
$ brew install libjpeg
$ git clone https://github.com/python-pillow/Pillow.git
$ cd Pillow
$ pip3 install . --no-binary :all: --no-use-pep517
Install matplotlib
$ git clone https://github.com/matplotlib/matplotlib.git
Then you need to manually download qhull and extract the archive. (http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz on Qhull Downloads)
You will get a folder named qhull-2020.2. You then have to place the folder at matplotlib/build. The build folder may not exist so you might have to create it.
Lastly, the following command will install the matplotlib on your M1 mac.
$ cd matplotlib
$ pip3 install . --no-binary :all:
Tested for Python 3.9.1 on non-Rosetta terminal on M1 Mac mini (Big Sur 11.2.1).
I solved this by just uninstalling homebrew first and downloaded matplotlib with python3. After that i reinstalled homebrew using non-rosetta terminal. Idk how it works cause im very new to these stuff but what works works i guess.
I solved this by realizing that I had two seperate Python instances installed. When you run which python3 you get the path of your Python installation. Check to see if the path corresponds to the Python version you installed.
I fixed it by uninstalling the version of Python3 I had installed with homebrew with brew uninstall python3.
When I did which python3 again it showed a different Python installation path. I then did pip3 install Matplotlib and I was able to import Matplotlib.
1. Uninstall Following Package
pip uninstall pillow
pip uninstall numpy
pip uninstall wordcloud
pip uninstall matplotlib
pip uninstall pyparsing
pip uninstall kiwisolver
pip uninstall python-dateutil
pip uninstall cycler
pip uninstall packaging
pip uninstall fonttools
pip uninstall contourpy
pip uninstall six
2. Install matplotlib
pip install matplotlib
I originally installed python 3.9 using homebrew, but my matplotlib problem was fixed by uninstalling python and reinstalling using the download from the python website(because of architecture problems).
I found another nice way with pyenv,miniforge and conda.
pyenv install miniforge3-4.10
conda create -n env_new python=3.9
conda activate env_new
conda install poetry
peotry new project
poetry add matplotlib
Maybe it is not perfect, but it works for a variety of moduls and you can even choose python=3.8 and other python versions and everything is running on the M1.
I installed "pdfminer" in virtual environment of conda.
I installed and reinstalled the library with following commands :
conda install -c conda-forge pdfminer
conda install -c conda-forge/label/cf201901 pdfminer
conda install -c conda-forge/label/cf202003 pdfminer
I got the same error all the time. It was like this:
/home/hamza/anaconda3/envs/my/bin/python /home/hamza/PycharmProjects/practice/pdf_info.py
20191125
Traceback (most recent call last):
File "/home/hamza/PycharmProjects/practice/pdf_info.py", line 67, in <module>
from pdfminer.high_level import extract_text
File "/home/hamza/anaconda3/envs/my/lib/python3.7/site-packages/pdfminer/high_level.py", line 14, in <module>
from .utils import open_filename
ImportError: cannot import name 'open_filename' from 'pdfminer.utils' (/home/hamza/anaconda3/envs/my/lib/python3.7/site-packages/pdfminer/utils.py)
Process finished with exit code 1
Is there any alternate way to install this library or what we can do this resolve this error
I've installed rpy2 through pip install rpy2. After this in a Jupyter notebook the import works fine:
import rpy2
print(rpy2.__version__)
which returns 3.1.0.
However when I type this import rpy2.robjects as robjects, I get the following error:
ValueError: The system "%s" is not supported.
Does someone know where this error comes from and how to solve it?
I had exactly the same problem.
I uninstalled the package and reinstalled it with conda (as I use Jupyter notebook through Anaconda):
conda install rpy2
Doing this it worked just fine.
The version installed was 2.9.4. There may be an issue with the version 3.1.0 I believe.
I have a similar problem. I had previously installed rpy2 2.9.5 withpip3 install rpy2 and it worked fine. However, today I tried updating it with pip3 install --upgrade rpy2 and got the following error:
Collecting rpy2
Using cached https://files.pythonhosted.org/packages/62/bc/d43df0d9e96a38985a97d1cbdb5722e10cd8fa0da45686972f0b8fd18a67/rpy2-3.2.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-irk23ljv/rpy2/setup.py", line 21, in <module>
from rpy2 import situation
File "/tmp/pip-build-irk23ljv/rpy2/rpy2/situation.py", line 98
raise ValueError(f'The system {system} is currently not supported.')
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-irk23ljv/rpy2/
I can't just stick to the older version because what I'm actually trying to do is to install another Python package that has rpy2 listed as a dependency. The install fails with the same error message.
Any update on the subject?
Edit
It looks like this might be a compatibility issue with Python 3.5 -- see https://bitbucket.org/rpy2/rpy2/issues/580/installing-rpy2-on-travis-with-pip. I've just opened an issue here: https://github.com/rpy2/rpy2/issues/356
I have installed electrum alongwith python 3.4, But when i run electrum it gives me below error. And I installed pyqt5 without --no-deps.
pip3.4 install pyqt5 --no-deps
pip3.4 install https://download.electrum.org/3.1.3/Electrum-3.1.3.tar.gz
#electrum
Traceback (most recent call last):
File "/usr/local/bin/electrum", line 418, in <module>
d.init_gui(config, plugins)
File "/usr/local/lib/python3.4/site-packages/electrum/daemon.py", line 308, in init_gui
gui = __import__('electrum_gui.' + gui_name, fromlist=['electrum_gui'])
File "/usr/local/lib/python3.4/site-packages/electrum_gui/qt/__init__.py", line 35, in <module>
from PyQt5.QtGui import *
ImportError: No module named 'sip'
I also upgraded pip. Getting error with deps:
pip3.4 install pyqt5
# pip3.4 install pyqt5
Requirement already satisfied: pyqt5 in /usr/local/lib/python3.4/site-packages
Collecting sip>=4.19.1 (from pyqt5)
Could not find a version that satisfies the requirement sip>=4.19.1 (from pyqt5) (from versions: )
No matching distribution found for sip>=4.19.1 (from pyqt5)
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I think the problem is because you are using Python 3.4.
According to the documentation of PyQt5, if you install from wheel, Python 3.5 is the minimum requirement.
Not a Problem just try it
First, activate your virtual env in your cmd using this,
./utfod/Scripts/activate
If error come like: cannot be loaded because running scripts is disabled on this system, Then for Solution execute this,
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
command first in powershell then
./utfod/Scripts/activate
I'm trying to install Tweepy on an Ubuntu VM and I'm running into way more issues than I should be. My first step was to successfully get pip installed. After that I tried:
pip install tweepy
which returns:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3020, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 616, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 629, in _build_from_requirements
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 807, in resolve
pkg_resources.DistributionNotFound: pip==1.5.4
The most that I can gather from that error message is that it can't find pip version 1.5.4. However, if I ask it whereis pip it returns:
pip: /usr/local/bin/pip2.7 /usr/local/bin/pip /usr/share/man/man1/pip.1.gz
So I know pip is installed. I decided to try the other method listed and do
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
But that only seems to partially install with error messages returning. Trying whereis tweepy after that method returns nothing.
Can anyone make sense of why this simple install isn't working for me?
This issue was resolved by using another fresh Ubuntu VM install and once again trying the manual installation by using
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
For whatever reason, it now works. The answer is officially voodoo.