pandas: Can't install Pandas on Mac M1

Environment Mac M1 Python 3.8.2 created using Xcode Command Line Tools for M1 Macs

On trying to install pandas, it failed and it returns very long erorr message starts as below

(py382tf) mgd@MGD ~ % pip install pandas Collecting pandas Using cached https://files.pythonhosted.org/packages/8a/6f/7fcef020b5b305862cacf376183eaa0f907f2fa42f0b687b2a9a2c6cda4d/pandas-1.2.3.tar.gz Installing build dependencies … error ERROR: Command errored out with exit status 1: command: /Users/mgd/py382tf/bin/python3 /Users/mgd/py382tf/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/px/zqhcsbbx4yxfmhc7927tnfj00000gn/T/pip-build-env-orb4vxpv/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple – setuptools wheel ‘Cython>=0.29.21,❤️’ ‘numpy==1.16.5; python_version==’“'”‘3.7’“'”’ and platform_system!=‘"’“‘AIX’”‘"’’ ‘numpy==1.17.3; python_version==’“'”‘3.8’“'”’ and platform_system!=‘"’“‘AIX’”‘"’’ ‘numpy==1.16.5; python_version==’“'”‘3.7’“'”’ and platform_system==‘"’“‘AIX’”‘"’’ ‘numpy==1.17.3; python_version==’“'”‘3.8’“'”’ and platform_system==‘"’“‘AIX’”‘"’’ ‘numpy; python_version>=’“'”‘3.9’“'”‘’ cwd: None Complete output (4451 lines): Ignoring numpy: markers ‘python_version == “3.7” and platform_system != “AIX”’ don’t match your environment Ignoring numpy: markers ‘python_version == “3.7” and platform_system == “AIX”’ don’t match your environment Ignoring numpy: markers ‘python_version == “3.8” and platform_system == “AIX”’ don’t match your environment Ignoring numpy: markers ‘python_version >= “3.9”’ don’t match your environment Collecting setuptools Using cached https://files.pythonhosted.org/packages/9e/d4/b99a960314121a003e9f39c61dfde01a1010bb47661e193a7722f7f32d52/setuptools-54.2.0-py3-none-any.whl Collecting wheel Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl Collecting Cython<3,>=0.29.21 Using cached https://files.pythonhosted.org/packages/9e/98/bff39b3acaebbc6102be71797f655bbe60738f7339db4ad7bd0772c08daf/Cython-0.29.22-py2.py3-none-any.whl Collecting numpy==1.17.3 Using cached https://files.pythonhosted.org/packages/b6/d6/be8f975f5322336f62371c9abeb936d592c98c047ad63035f1b38ae08efe/numpy-1.17.3.zip Installing collected packages: setuptools, wheel, Cython, numpy Running setup.py install for numpy: started Running setup.py install for numpy: finished with status ‘error’ ERROR: Command errored out with exit status 1: command: /Users/mgd/py382tf/bin/python3 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/var/folders/px/zqhcsbbx4yxfmhc7927tnfj00000gn/T/pip-install-x_x_2bsb/numpy/setup.py’“'”‘; file=’“'”‘/private/var/folders/px/zqhcsbbx4yxfmhc7927tnfj00000gn/T/pip-install-x_x_2bsb/numpy/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record /private/var/folders/px/zqhcsbbx4yxfmhc7927tnfj00000gn/T/pip-record-73r6zlw4/install-record.txt --single-version-externally-managed --prefix /private/var/folders/px/zqhcsbbx4yxfmhc7927tnfj00000gn/T/pip-build-env-orb4vxpv/overlay --compile --install-headers /Users/mgd/py382tf/include/site/python3.8/numpy cwd: /private/var/folders/px/zqhcsbbx4yxfmhc7927tnfj00000gn/T/pip-install-x_x_2bsb/numpy/ Complete output (4428 lines): Running from numpy source directory.

  Note: if you need reliable uninstall behavior, then install
  with pip instead of using `setup.py install`:

    - `pip install .`       (from a git repo or downloaded source
                             release)
    - `pip install numpy`   (last NumPy release on PyPi)


  blas_opt_info:
  blas_mkl_info:
  customize UnixCCompiler
    libraries mkl_rt not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  blis_info:
  customize UnixCCompiler
    libraries blis not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  openblas_info:
  customize UnixCCompiler
  customize UnixCCompiler
    libraries openblas not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  atlas_3_10_blas_threads_info:
  Setting PTATLAS=ATLAS
  customize UnixCCompiler
    libraries tatlas not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  atlas_3_10_blas_info:
  customize UnixCCompiler
    libraries satlas not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  atlas_blas_threads_info:
  Setting PTATLAS=ATLAS
  customize UnixCCompiler
    libraries ptf77blas,ptcblas,atlas not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  atlas_blas_info:
  customize UnixCCompiler
    libraries f77blas,cblas,atlas not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
    NOT AVAILABLE

  accelerate_info:
  customize UnixCCompiler
    libraries accelerate not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
  Library accelerate was not found. Ignoring
  customize UnixCCompiler
    libraries veclib not found in ['/Users/mgd/py382tf/lib', '/usr/lib']
  Library veclib was not found. Ignoring

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 34 (14 by maintainers)

Most upvoted comments

Hello,

I faced the same problem, and solved it by doing the following steps:

  1. open finder
  2. locate terminal
  3. right click on the terminal icon
  4. click get info
  5. click open with rosetta
  6. open a new terminal
  7. use your normal package downloading method like “pip3 install pandas”

This should fix the issue.

I installed pandas in my M1 Macbook Pro today.

  • Installed Python 3.9.4 using Homebrew.
  • Then just did pip3 install pandas

It took a while but not more than 3 minutes though. It got successfully installed.

Here’s my log

❯ pip3 install pandas

Collecting pandas
  Downloading pandas-1.2.4.tar.gz (5.5 MB)
     |████████████████████████████████| 5.5 MB 855 kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting numpy>=1.16.5
  Using cached numpy-1.20.2-cp39-cp39-macosx_11_0_arm64.whl
Collecting pytz>=2017.3
  Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 8.8 MB/s
Collecting python-dateutil>=2.7.3
  Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB 10.5 MB/s
Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Building wheels for collected packages: pandas
  Building wheel for pandas (PEP 517) ... /

done
  Created wheel for pandas: filename=pandas-1.2.4-cp39-cp39-macosx_11_0_arm64.whl size=9354006 sha256=87fead2b2cacdfdc448c444899dfffca3b82275635ac8d51a39790ede623e342
  Stored in directory: /Users/pks/Library/Caches/pip/wheels/1c/18/1d/96f6fb133a77724bc42fce621a44162d840d037b9289c4a874
Successfully built pandas
Installing collected packages: pytz, python-dateutil, numpy, pandas
Successfully installed numpy-1.20.2 pandas-1.2.4 python-dateutil-2.8.1 pytz-2021.1

Steps I took in a brand new M1 Macbook Air to make it work:

  • Updated Python via Homebrew (3.9.4)
  • Installed Cython (pip install cython)
  • Installed Numpy without PEP517 (pip install numpy --no-use-pep517)
  • Installed Pandas without PEP517 (pip install pandas --no-use-pep517)

clearly the solution is for Apple to send me an M1 MBP so i can ensure we have testing on the platform.

pip install numpy only works for numpy>=1.20 on M1. I think when you run pip install pandas, pip is trying to install a numpy of version < 1.20.

You could try to build pandas from source like this.

git clone https://github.com/pandas-dev/pandas.git
cd pandas
python -m pip install numpy cython pytz python-dateutil
python setup.py build_ext -j 8
python -m pip install -e . --no-build-isolation --no-use-pep517

@jbrockmendel We probably should set a min numpy version in pyproject.toml for M1.

Steps I took in a brand new M1 Macbook Air to make it work:

  • Updated Python via Homebrew (3.9.4)
  • Installed Cython (pip install cython)
  • Installed Numpy without PEP517 (pip install numpy --no-use-pep517)
  • Installed Pandas without PEP517 (pip install pandas --no-use-pep517)

my error for example comes from Docker. Even if I do all of this I’m not going to install it inside the image, which is where I’m getting the error from

My solutions are as shown below.

Discaimer: YMMV

I installed python3.8.10 with macOS 64-bit universal2 installer from python.org and faced the same issue when I run pip install pandas==1.0.5. For me one of the followings worked.

Method 1

  • change my zsh type to intel one
arch -x86_64 zsh
  • run pip install pandas==1.0.5 and no error appeared.

Method 2

  • use macOS 64-bit intel installer in the first place to install python3.8.10
  • run pip install pandas==1.0.5 and no error appeared.

Sounds like this issues is relatively resolved in 1.3 at least so closing. Happy to reopen if that didn’t fix things.

We don’t currently have wheels for arm64(M1) so pip will try to build pandas from source. I think a fix was merged in 1.3 that should allow everyone to install/build pandas from a clean environment. In a future release, we’ll try to get arm64/universal2 wheels out.

I’m having the same problem as @mkismy. Trying to install Pandas 1.3.4 via Poetry, running Python 3.9.8