Question

I have successfully installed MPICH on Ubuntu 12.04 and can get the simple test C programs to compile and run as expected.

Now I am trying to use pip to install mpi4py, simply via pip install mpi4py. I first executed sudo apt-get build-dep python-mpi4py which worked fine.

I'm working with virtualenv, so this mpi4py installation is not with sudo (and should not be).

Here's the command and the error that I hit after a lengthy set of console output that looks like normal compile stuff (I can print all of the console output if needed, but I think most of it is standard compiler warnings that indicate no problems).

(local-dev)espears@espears-w:~$ pip install mpi4py
src/ext/mpi_swig.c: In function ‘SWIG_Python_AddErrorMsg’:

src/ext/mpi_swig.c:859:5: error: format not a string literal and no format arguments [-Werror=format-security]

cc1: some warnings being treated as errors

error: command '/usr/bin/mpicc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/espears/.virtualenvs/local-dev/bin/python -c "import setuptools, tokenize;__file__='/home/espears/.virtualenvs/local-dev/build/mpi4py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5o6OwN-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/espears/.virtualenvs/local-dev/include/site/python2.7 failed with error code 1 in /home/espears/.virtualenvs/local-dev/build/mpi4py
Traceback (most recent call last):
  File "/home/espears/.virtualenvs/local-dev/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 31: ordinal not in range(128)

But, which mpicc gives the expected result: /usr/bin/mpicc and as mentioned above, if I use this mpicc to compile simple .c test programs, they work fine.

I've seen some links describing a flag option fPIC for compiling MPI, but, I merely used apt-get to install MPI and specifically want to only rely on native Ubuntu packages for these tools, as opposed to maintaining separate installation instructions for manually building them.

How can I determine why mpicc is failing within the mpi4py installation process?

Added

The following from the console output seems to be the compilation command that causes the trouble.

building 'mpi4py._mpi_swig' extension

/usr/bin/mpicc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/ext/mpi_swig.c -o build/temp.linux-x86_64-2.7/src/ext/mpi_swig.o

This gives the following error when I try from the command line myself:

(local-dev)espears@espears-w:~$ /usr/bin/mpicc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/ext/mpi_swig.c -o build/temp.linux-x86_64-2.7/src/ext/mpi_swig.o
gcc: error: src/ext/mpi_swig.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Was it helpful?

Solution

I was able to successfully work around this with no changes to anything in my system simply by pointing pip at the MPI4PY package url, rather than the package name:

pip install https://bitbucket.org/mpi4py/mpi4py/downloads/mpi4py-1.3.1.tar.gz

OTHER TIPS

A similar problem was encountered on Ubuntu 18.04 with openmpi-4.0.0. Solved by installing older version of openmpi-2.1.6.

apt-get install openmpi=2.1.6
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top