how to install pandas on m1 Mac

Viewed 8135
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -DNPY_NO_DEPRECATED_API=0 -Ipandas/_libs/src/ujson/python -Ipandas/_libs/src/ujson/lib -Ipandas/_libs/src/datetime -I/Users/jesse/Desktop/ssc/pythonProject3/venv/lib/python3.8/site-packages/numpy/core/include -I/Users/jesse/Desktop/ssc/pythonProject3/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c pandas/_libs/src/ujson/python/ujson.c -o build/temp.macosx-10.14.6-arm64-3.8/pandas/_libs/src/ujson/python/ujson.o -D_GNU_SOURCE -Wno-unused-function
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -DNPY_NO_DEPRECATED_API=0 -Ipandas/_libs/src/ujson/python -Ipandas/_libs/src/ujson/lib -Ipandas/_libs/src/datetime -I/Users/jesse/Desktop/ssc/pythonProject3/venv/lib/python3.8/site-packages/numpy/core/include -I/Users/jesse/Desktop/ssc/pythonProject3/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c pandas/_libs/src/ujson/python/objToJSON.c -o build/temp.macosx-10.14.6-arm64-3.8/pandas/_libs/src/ujson/python/objToJSON.o -D_GNU_SOURCE -Wno-unused-function
    pandas/_libs/src/ujson/python/objToJSON.c:181:12: error: use of undeclared identifier 'NUMPY_IMPORT_ARRAY_RETVAL'
        return NUMPY_IMPORT_ARRAY_RETVAL;
               ^
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/jesse/Desktop/ssc/pythonProject3/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ky/s4qqls154f9c4j5lfcfspbpm0000gn/T/pip-install-t5zlzk09/pandas_67e63708ec954c589e697c9f10e3730c/setup.py'"'"'; __file__='"'"'/private/var/folders/ky/s4qqls154f9c4j5lfcfspbpm0000gn/T/pip-install-t5zlzk09/pandas_67e63708ec954c589e697c9f10e3730c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ky/s4qqls154f9c4j5lfcfspbpm0000gn/T/pip-record-cnus0d48/install-record.txt --single-version-externally-managed --compile --install-headers /Users/jesse/Desktop/ssc/pythonProject3/venv/include/site/python3.8/pandas Check the logs for full command output.
(base) 

I want to download pandas on Mac mini using PyCharm.

What should I do?

7 Answers

This was answered on:

Trouble installing Pandas on new MacBook Air M1

python3 -m pip install virtualenv
virtualenv -p python3.8 venv
source venv/bin/activate
pip install --upgrade pip
pip install numpy cython
git clone https://github.com/pandas-dev/pandas.git
cd pandas
python3 setup.py install

While caeneb's trick worked like a charm, I found that upgrading your python to a later version and updating pip worked as well.

for me these where the commands that did the trick (I manage my python installation with pyenv)

pyenv install 3.9.9
pyenv global 3.9.9 # use this python version as the default
pip install pandas # just works

I guess that without pyenv you can simply run the following commands (untested)

brew install python@3.9.9
$(brew --prefix)/bin/python3.9 -m pip install pandas # makes sure to use the right pip

You have to have numpy installed in your environment to build pandas from source for all versions of pandas that come without a pyproject.toml. Please install numpy first and try again.


If numpy is installed on your machine you may need to update the version using pip install numpy -U or an equivalent command executed via PyCharm GUI.

I recommend you to use conda, so that you can install virtual environments, also with different python version and eventually with different R (and also node.js). Much simpler and programs are pre-compiled (and conda was created for such cases).

Else, are you sure you have xcode installed? Check on Apple store. Xcode is the "SDK" (developer toolkit) of Apple with the compiler: the clang: you doesn't have it, so the error. It gives you also other tools which are generally needed for pip. Note: you should also execute manually also one xcode command, to be able to accept the xcode condition (else you may have problem on scripts which uses xcode).

This works for me pip install git+git://github.com/pandas-dev/pandas.git

From manually reviewing the numpy git log, downgrading numpy using pip install numpy==1.18.5 and then

OPENBLAS="$(brew --prefix openblas)" MACOSX_DEPLOYMENT_TARGET=12.4 pip3 install pandas==0.25.3 --no-use-pep517

After installation of pandas, I was able to upgrade numpy again

$pip install pandas

For installing pip in Mac :

$curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

OR

  • Install python with homebrew:

    brew install python

  • Make sure of correct path:

    $which python

  • Now install pandas:

    $pip install pandas

Related