'Failed to build mpi4py on Mac: x86_64-apple-darwin13.4.0-clang: command not found

My configuration is python 3.9.7, pip 21.2.4, Mac version 12.3. detail about this Error:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ mpi4py
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting mpi4py
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/20/50/d358fe2b56075163b75eca30c2faa6455c50b9978dd26f0fc4e3879b1062/mpi4py-3.1.3.tar.gz (2.5 MB)
     |████████████████████████████████| 2.5 MB 2.2 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
...
...
...
  building 'mpi4py.dl' extension
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/yrs/opt/anaconda3/include -arch x86_64 -I/Users/yrs/opt/anaconda3/include -fPIC -O2 -isystem /Users/yrs/opt/anaconda3/include -arch x86_64 -DHAVE_DLFCN_H=1 -DHAVE_DLOPEN=1 -I/Users/yrs/opt/anaconda3/include/python3.9 -c src/dynload.c -o build/temp.macosx-10.9-x86_64-3.9/src/dynload.o
  clang -bundle -undefined dynamic_lookup -Wl,-rpath,/Users/yrs/opt/anaconda3/lib -L/Users/yrs/opt/anaconda3/lib -L/Users/yrs/opt/anaconda3/lib -Wl,-rpath,/Users/yrs/opt/anaconda3/lib -L/Users/yrs/opt/anaconda3/lib build/temp.macosx-10.9-x86_64-3.9/src/dynload.o -Lbuild/temp.macosx-10.9-x86_64-3.9 -ldl -o build/lib.macosx-10.9-x86_64-3.9/mpi4py/dl.cpython-39-darwin.so
  checking for MPI compile and link ...
  /Users/yrs/opt/anaconda3/bin/mpicc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/yrs/opt/anaconda3/include -arch x86_64 -I/Users/yrs/opt/anaconda3/include -fPIC -O2 -isystem /Users/yrs/opt/anaconda3/include -arch x86_64 -I/Users/yrs/opt/anaconda3/include/python3.9 -c _configtest.c -o _configtest.o
  /Users/yrs/opt/anaconda3/bin/mpicc: line 301: x86_64-apple-darwin13.4.0-clang: command not found
  failure.
  removing: _configtest.c _configtest.o
  error: Cannot compile MPI programs. Check your configuration!!!
  ----------------------------------------
  ERROR: Failed building wheel for mpi4py
Failed to build mpi4py
ERROR: Could not build wheels for mpi4py which use PEP 517 and cannot be installed directly

I try to install mpi4py but fail, i don't know how to do this...(btw i don't want to install Xcode :<)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source