I am trying to install mpi4py in default python environment used by anaconda:
python3.9 -m pip install mpi4py
which produces error during installation
python -m pip install mpi4py
Collecting mpi4py
Using cached mpi4py-3.1.3.tar.gz (2.5 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: mpi4py
Building wheel for mpi4py (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /home/gleb/anaconda3/bin/python /home/gleb/anaconda3/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmp75wsbtz5
cwd: /tmp/pip-install-84g0ez5h/mpi4py_2ac6e87b98de43d3827e1b2951c5c4ff
Complete output (156 lines):
running bdist_wheel
running build
running build_src
running build_py
creating build
creating build/lib.linux-x86_64-cpython-39
creating build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/bench.py -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/__main__.py -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/run.py -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/__init__.py -> build/lib.linux-x86_64-cpython-39/mpi4py
creating build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/server.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/pool.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/_lib.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/_base.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/aplus.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/__main__.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/__init__.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/_core.py -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
creating build/lib.linux-x86_64-cpython-39/mpi4py/util
copying src/mpi4py/util/dtlib.py -> build/lib.linux-x86_64-cpython-39/mpi4py/util
copying src/mpi4py/util/pkl5.py -> build/lib.linux-x86_64-cpython-39/mpi4py/util
copying src/mpi4py/util/__init__.py -> build/lib.linux-x86_64-cpython-39/mpi4py/util
copying src/mpi4py/py.typed -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/__main__.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/dl.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/MPI.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/__init__.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/bench.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/run.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/MPI.pxd -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/libmpi.pxd -> build/lib.linux-x86_64-cpython-39/mpi4py
copying src/mpi4py/__init__.pxd -> build/lib.linux-x86_64-cpython-39/mpi4py
creating build/lib.linux-x86_64-cpython-39/mpi4py/include
creating build/lib.linux-x86_64-cpython-39/mpi4py/include/mpi4py
copying src/mpi4py/include/mpi4py/mpi4py.MPI.h -> build/lib.linux-x86_64-cpython-39/mpi4py/include/mpi4py
copying src/mpi4py/include/mpi4py/mpi4py.h -> build/lib.linux-x86_64-cpython-39/mpi4py/include/mpi4py
copying src/mpi4py/include/mpi4py/mpi4py.MPI_api.h -> build/lib.linux-x86_64-cpython-39/mpi4py/include/mpi4py
copying src/mpi4py/include/mpi4py/mpi4py.i -> build/lib.linux-x86_64-cpython-39/mpi4py/include/mpi4py
copying src/mpi4py/include/mpi4py/mpi.pxi -> build/lib.linux-x86_64-cpython-39/mpi4py/include/mpi4py
copying src/mpi4py/futures/_lib.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/__main__.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/aplus.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/__init__.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/pool.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/server.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/futures/_core.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/futures
copying src/mpi4py/util/dtlib.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/util
copying src/mpi4py/util/pkl5.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/util
copying src/mpi4py/util/__init__.pyi -> build/lib.linux-x86_64-cpython-39/mpi4py/util
running build_clib
MPI configuration: [mpi] from 'mpi.cfg'
MPI C compiler: /home/gleb/anaconda3/bin/mpicc
MPI C++ compiler: /home/gleb/anaconda3/bin/mpicxx
MPI F compiler: /home/gleb/anaconda3/bin/mpifort
MPI F90 compiler: /home/gleb/anaconda3/bin/mpif90
MPI F77 compiler: /home/gleb/anaconda3/bin/mpif77
checking for library 'lmpe' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
building 'mpe' dylib library
creating build/temp.linux-x86_64-cpython-39
creating build/temp.linux-x86_64-cpython-39/src
creating build/temp.linux-x86_64-cpython-39/src/lib-pmpi
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c src/lib-pmpi/mpe.c -o build/temp.linux-x86_64-cpython-39/src/lib-pmpi/mpe.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
warning: build_clib: command '/home/gleb/anaconda3/bin/mpicc' failed with exit code 127
warning: build_clib: building optional library "mpe" failed
checking for library 'vt-mpi' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
checking for library 'vt.mpi' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
building 'vt' dylib library
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c src/lib-pmpi/vt.c -o build/temp.linux-x86_64-cpython-39/src/lib-pmpi/vt.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
warning: build_clib: command '/home/gleb/anaconda3/bin/mpicc' failed with exit code 127
warning: build_clib: building optional library "vt" failed
checking for library 'vt-mpi' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
checking for library 'vt.mpi' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
building 'vt-mpi' dylib library
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c src/lib-pmpi/vt-mpi.c -o build/temp.linux-x86_64-cpython-39/src/lib-pmpi/vt-mpi.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
warning: build_clib: command '/home/gleb/anaconda3/bin/mpicc' failed with exit code 127
warning: build_clib: building optional library "vt-mpi" failed
checking for library 'vt-hyb' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
checking for library 'vt.ompi' ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
failure.
removing: _configtest.c _configtest.o
building 'vt-hyb' dylib library
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -c src/lib-pmpi/vt-hyb.c -o build/temp.linux-x86_64-cpython-39/src/lib-pmpi/vt-hyb.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: command not found
warning: build_clib: command '/home/gleb/anaconda3/bin/mpicc' failed with exit code 127
warning: build_clib: building optional library "vt-hyb" failed
running build_ext
MPI configuration: [mpi] from 'mpi.cfg'
MPI C compiler: /home/gleb/anaconda3/bin/mpicc
MPI C++ compiler: /home/gleb/anaconda3/bin/mpicxx
MPI F compiler: /home/gleb/anaconda3/bin/mpifort
MPI F90 compiler: /home/gleb/anaconda3/bin/mpif90
MPI F77 compiler: /home/gleb/anaconda3/bin/mpif77
checking for dlopen() availability ...
checking for header 'dlfcn.h' ...
gcc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -I/home/gleb/anaconda3/include/python3.9 -c _configtest.c -o _configtest.o
success!
removing: _configtest.c _configtest.o
success!
checking for library 'dl' ...
gcc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -I/home/gleb/anaconda3/include/python3.9 -c _configtest.c -o _configtest.o
gcc -pthread -B /home/gleb/anaconda3/compiler_compat _configtest.o -Lbuild/temp.linux-x86_64-cpython-39 -ldl -o _configtest
success!
removing: _configtest.c _configtest.o _configtest
checking for function 'dlopen' ...
gcc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -I/home/gleb/anaconda3/include/python3.9 -c _configtest.c -o _configtest.o
gcc -pthread -B /home/gleb/anaconda3/compiler_compat _configtest.o -Lbuild/temp.linux-x86_64-cpython-39 -ldl -o _configtest
success!
removing: _configtest.c _configtest.o _configtest
building 'mpi4py.dl' extension
gcc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -DHAVE_DLFCN_H=1 -DHAVE_DLOPEN=1 -I/home/gleb/anaconda3/include/python3.9 -c src/dynload.c -o build/temp.linux-x86_64-cpython-39/src/dynload.o
gcc -pthread -B /home/gleb/anaconda3/compiler_compat -shared -Wl,-rpath,/home/gleb/anaconda3/lib -Wl,-rpath-link,/home/gleb/anaconda3/lib -L/home/gleb/anaconda3/lib -L/home/gleb/anaconda3/lib -Wl,-rpath,/home/gleb/anaconda3/lib -Wl,-rpath-link,/home/gleb/anaconda3/lib -L/home/gleb/anaconda3/lib build/temp.linux-x86_64-cpython-39/src/dynload.o -Lbuild/temp.linux-x86_64-cpython-39 -ldl -o build/lib.linux-x86_64-cpython-39/mpi4py/dl.cpython-39-x86_64-linux-gnu.so
checking for MPI compile and link ...
/home/gleb/anaconda3/bin/mpicc -pthread -B /home/gleb/anaconda3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/gleb/anaconda3/include -I/home/gleb/anaconda3/include -fPIC -O2 -isystem /home/gleb/anaconda3/include -fPIC -I/home/gleb/anaconda3/include/python3.9 -c _configtest.c -o _configtest.o
/home/gleb/anaconda3/bin/mpicc: line 301: x86_64-conda_cos6-linux-gnu-cc: 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
Then I tried
sudo pip install mpi4py
that installed the package correctly but into another python environment so python does not see it
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpi4py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mpi4py'
Finally I've tried simply
sudo apt install python3-mpi4py
it installed package correclty but my python3 enviroment still does not see it.
I also tried
conda install -c conda-forge mpi4py
which does not work as well:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: - failed with initial frozen solve. Retrying with flexible solve.
how could I execute python3.9 -m pip install mpi4py with sudo ?