Problems with installing pyprecice on MacOS

I am following the precice tutorial, and got an error I cannot resolve:
When I “import precice” in python, I get the following error:

~/Downloads/part1/skeleton/generator$ python3 generator.py
Traceback (most recent call last):
File “/Users/weinhartt/Downloads/part1/skeleton/generator/generator.py”, line 3, in
import precice
File “/Users/weinhartt/Library/Python/3.9/lib/python/site-packages/precice/init.py”, line 3, in
from cyprecice import Interface, action_read_iteration_checkpoint, action_write_iteration_checkpoint, action_write_initial_data, get_version_information
ImportError: dlopen(/Users/weinhartt/Library/Python/3.9/lib/python/site-packages/cyprecice.cpython-39-darwin.so, 2): Symbol not found: __ZN5boost15program_options19options_description21m_default_line_lengthE
Referenced from: /Users/weinhartt/Library/Python/3.9/lib/python/site-packages/cyprecice.cpython-39-darwin.so
Expected in: flat namespace
in /Users/weinhartt/Library/Python/3.9/lib/python/site-packages/cyprecice.cpython-39-darwin.so

I am using MacOS Big Sur, SDK 11.0, python 3.9. I have used brew to reinstall boost, petsc, openmpi, then I installed precice and pyprecice, without errors or warning, see below.

Any help is appreciated.

~$ brew reinstall boost
==> Downloading https://homebrew.bintray.com/bottles/boost-1.75.0_1.big_sur.bottle.tar.gz
Already downloaded: /Users/weinhartt/Library/Caches/Homebrew/downloads/f3136c231545902ba78c4f23a11c4c54cb25503b0621f752eaff050864696ad4–boost-1.75.0_1.big_sur.bottle.tar.gz
==> Reinstalling boost
==> Pouring boost-1.75.0_1.big_sur.bottle.tar.gz
:beer: /usr/local/Cellar/boost/1.75.0_1: 15,058 files, 524.2MB

~/Code/precice-2.2.0/build$ cmake . -DPRECICE_PETScMapping=OFF && make && make install
– === CONFIGURATION ===
– Library version to build: 2.2.0
– Build configuration: Debug
– Build shared libraries: OFF
– Target system: Darwin-20.3.0
– Host system: Darwin-20.3.0
– Library architecture:
– CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
– CXX compiler flags:
– CXX linker: /Library/Developer/CommandLineTools/usr/bin/ld
– Install prefix: /usr/local
– Source directory: /Users/weinhartt/Code/precice-2.2.0
– Binary directory: /Users/weinhartt/Code/precice-2.2.0/build
– Configure package generation: ON
– Install tests/testfiles: OFF
– Additional CTest MPI Flags:

– === ENABLED FEATURES ===

  • MPICommunication, Enables the MPI communication back-end.

    This enables the MPI communication back-end which is highly recommended on multi-node systems.
    See the documentation of the CMake module FindMPI to control its functionality.

    This feature can be enabled/disabled by setting the PRECICE_MPICommunication CMake option.

  • PythonActions, Enables the support for user-defined python actions.

    preCICE allows to manipulate coupling data at runtime using configurable actions.
    This feature enables the support for user-defined actions written in Python based on numpy.

    This feature can be enabled/disabled by setting the PRECICE_PythonActions CMake option.

  • CBindings, Enables the native C bindings.

    preCICE provides native bindings for C, which are compiled into the library.
    This feature enables the compilation and installation of the bindings into the library.
    Note that we strongly recommend to compile with C bindings enabled for compatibility reasons.

    This feature can be enabled/disabled by setting the PRECICE_ENABLE_C CMake option.

  • FortranBindings, Enables the native Fortran bindings.

    preCICE provides native bindings for Fortran, which are compiled into the library.
    This feature enables the compilation and installation of the bindings into the library.
    Note that we strongly recommend to compile with Fortran bindings enabled for compatibility reasons.

    This feature can be enabled/disabled by setting the PRECICE_ENABLE_FORTRAN CMake option.

– === DISABLED FEATURES ===

  • PETScMapping, Enables the PETSc-powered radial basic function mappings.

    This enables the PETSc-based variant of radial basis function mappings which can run in parallel,
    also across different compute nodes. This is highly recommended for large cases running in parallel.

    This feature can be enabled/disabled by setting the PRECICE_PETScMapping CMake option.
    Requires MPICommunication.

– === DEPENDENCIES ===
– Validating Eigen
– Validating Prettyprint - success [cached]
– Validating LibXml2
– Validating Prettyprint - success [cached]
– Validating JSON
– Validating Prettyprint - success [cached]
– Validating Prettyprint
– Validating Prettyprint - success [cached]
– MPI Version: Open MPI v4.0.5, package: Open MPI brew@BigSur Distribution, ident: 4.0.5, repo rev: v4.0.5, Aug 26, 2020
– PETSc support disabled
– Validating LibPython
– Validating Prettyprint - success [cached]
– Validating NumPy
– Validating Prettyprint - success [cached]

– === TARGETS & PACKAGES ===
– Including test sources
– Compressing manpage: /Users/weinhartt/Code/precice-2.2.0/build/packaging/man1/binprecice.1
Debian package generator disabled: Install prefix is not “/usr”
– Compressing changelog

– === TESTS ===
– Test precice.acceleration
– Test precice.action
– Test precice.com
– Test precice.com.mpiports - skipped (OpenMPI)
– Test precice.cplscheme
– Test precice.io
– Test precice.m2n
– Test precice.m2n.mpiports - skipped (OpenMPI)
– Test precice.mapping
– Test precice.mapping.petrbf - skipped
– Test precice.math
– Test precice.mesh
– Test precice.partition
– Test precice.interface
– Test precice.serial
– Test precice.parallel
– Test precice.query
– Test precice.testing
– Test precice.utils
– Test precice.xml
– Test precice.solverdummy.build.cpp
– Test precice.solverdummy.build.c
– Test precice.solverdummy.build.fortran
– Test precice.solverdummy.run.cpp-cpp
– Test precice.solverdummy.run.c-c
– Test precice.solverdummy.run.fortran-fortran
– Test precice.solverdummy.run.cpp-c
– Test precice.solverdummy.run.cpp-fortran
– Test precice.solverdummy.run.c-fortran
– Configuring done
– Generating done
– Build files have been written to: /Users/weinhartt/Code/precice-2.2.0/build
– Found Git: /usr/local/bin/git (found version “2.30.0”)
– Revision status: Detection failed
[ 0%] Built target GitRevision
[ 62%] Built target precice
[ 99%] Built target testprecice
[100%] Built target binprecice
– Found Git: /usr/local/bin/git (found version “2.30.0”)
– Revision status: Detection failed
[ 0%] Built target GitRevision
[ 62%] Built target precice
[ 99%] Built target testprecice
[100%] Built target binprecice
Install the project…
– Install configuration: “Debug”
– Installing: /usr/local/lib/libprecice.a
– Up-to-date: /usr/local/include/precice/SolverInterface.hpp
– Up-to-date: /usr/local/include/precice/SolverInterfaceC.h
– Up-to-date: /usr/local/include/precice/SolverInterfaceFortran.hpp
– Up-to-date: /usr/local/include/precice/SolverInterfaceFASTEST.hpp
– Up-to-date: /usr/local/bin/binprecice
– Up-to-date: /usr/local/share/precice/examples
– Up-to-date: /usr/local/share/precice/examples/solverdummies
– Up-to-date: /usr/local/share/precice/examples/solverdummies/solverdummies.doxys
– Up-to-date: /usr/local/share/precice/examples/solverdummies/precice-config.xml
– Up-to-date: /usr/local/share/precice/examples/solverdummies/README.md
– Up-to-date: /usr/local/share/precice/examples/solverdummies/cpp
– Up-to-date: /usr/local/share/precice/examples/solverdummies/cpp/CMakeLists.txt
– Up-to-date: /usr/local/share/precice/examples/solverdummies/cpp/solverdummy.cpp
– Up-to-date: /usr/local/share/precice/examples/solverdummies/cpp/README.md
– Up-to-date: /usr/local/share/precice/examples/solverdummies/cpp/test.cmake
– Up-to-date: /usr/local/share/precice/examples/solverdummies/fortran
– Up-to-date: /usr/local/share/precice/examples/solverdummies/fortran/CMakeLists.txt
– Up-to-date: /usr/local/share/precice/examples/solverdummies/fortran/solverdummy.f90
– Up-to-date: /usr/local/share/precice/examples/solverdummies/fortran/README.md
– Up-to-date: /usr/local/share/precice/examples/solverdummies/c
– Up-to-date: /usr/local/share/precice/examples/solverdummies/c/CMakeLists.txt
– Up-to-date: /usr/local/share/precice/examples/solverdummies/c/README.md
– Up-to-date: /usr/local/share/precice/examples/solverdummies/c/solverdummy.c
– Up-to-date: /usr/local/lib/cmake/precice/preciceTargets.cmake
– Installing: /usr/local/lib/cmake/precice/preciceTargets-debug.cmake
– Up-to-date: /usr/local/lib/cmake/precice/preciceConfig.cmake
– Up-to-date: /usr/local/lib/cmake/precice/preciceConfigVersion.cmake
– Up-to-date: /usr/local/share/man/man1
– Up-to-date: /usr/local/share/man/man1/binprecice.1.gz
– Up-to-date: /usr/local/lib/pkgconfig
– Up-to-date: /usr/local/lib/pkgconfig/libprecice.pc
– Up-to-date: /usr/local/share/doc/libprecice2/copyright
– Installing: /usr/local/share/lintian/overrides/libprecice2
– Up-to-date: /usr/local/share/doc/libprecice2/changelog.gz

~/Code/python-bindings$ pip3 install --user .
Processing /Users/weinhartt/Code/python-bindings
Installing build dependencies … done
Getting requirements to build wheel … done
Preparing wheel metadata … done
Requirement already satisfied: numpy in /usr/local/lib/python3.9/site-packages (from pyprecice==2.2.0.1+7.g814db22) (1.20.1)
Requirement already satisfied: mpi4py in /usr/local/lib/python3.9/site-packages (from pyprecice==2.2.0.1+7.g814db22) (3.0.3)
Building wheels for collected packages: pyprecice
Building wheel for pyprecice (PEP 517) … done
Created wheel for pyprecice: filename=pyprecice-2.2.0.1+7.g814db22-py2.py3-none-any.whl size=5754537 sha256=d5f9312cf520c9de40b227075095167d703b1494456fb3cdf55883f5c3de84bc
Stored in directory: /Users/weinhartt/Library/Caches/pip/wheels/a5/25/a8/8ec92057b72c5269060559ab4701d89a98516ef2a129d3c978
Successfully built pyprecice
Installing collected packages: pyprecice
Attempting uninstall: pyprecice
Found existing installation: pyprecice 2.2.0.1+7.g814db22
Uninstalling pyprecice-2.2.0.1+7.g814db22:
Successfully uninstalled pyprecice-2.2.0.1+7.g814db22
Successfully installed pyprecice-2.2.0.1+7.g814db22

Hi!

Have you checked whether building preCICE works as expected? Did you run the tests after installation? Your main problem does not seem to be the Python bindings itself, but it seems to be Boost

ImportError: dlopen(/Users/weinhartt/Library/Python/3.9/lib/python/site-packages/cyprecice.cpython-39-darwin.so, 2): Symbol not found: __ZN5boost15program_options19options_description21m_default_line_lengthE

I checked the bindings on my machine and they are not linked against Boost, but rather preCICE itself.

As quick workaround I would suggest to install an older version of Boost, e.g., Boost 1.74.0. I guess that is done via

brew install boost@1.74.0

Then recompile preCICE and the Pythonbindings.

Could you try that and report back?

1 Like

Thanks, Alex. Indeed, all tests failed.

The boost problem was that I had an old boost directory in my path (I am now using export PATH=/usr/local/Cellar/boost/1.75.0_1/include/:${PATH}), so boost was not found.

Some other libraries were not found as well (Eigen and many more), I solved this by adding the cmake option “-DBUILD_SHARED_LIBS=ON”.

I still have trouble with the tests using MPI, so I turned off MPI for now: “-DPRECICE_MPICommunication=OFF -DPRECICE_PETScMapping=OFF”.

Now the tests compile, and “import precice” works.

Great to hear that it was so easy to fix. Regarding the MPI issue maybe someone else can comment on that. Did you get any reasonable error message for the failing tests?

Hi, in order to have a more detailed look at the failure of the tests, could you run ctest --output-on-failure and paste the output here?

These are the errors I get when I use the cmake option “-DPRECICE_MPICommunication=ON”:

~/Code/precice/build$ ctest --output-on-failure
Test project /Users/weinhartt/Code/precice/build
Start 1: precice.acceleration
1/26 Test #1: precice.acceleration …Child killed***Exception: 0.15 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  2: precice.action

2/26 Test #2: precice.action …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  3: precice.com

3/26 Test #3: precice.com …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  4: precice.cplscheme

4/26 Test #4: precice.cplscheme …Child killed***Exception: 0.12 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  5: precice.io

5/26 Test #5: precice.io …Child killed***Exception: 0.12 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  6: precice.m2n

6/26 Test #6: precice.m2n …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  7: precice.mapping

7/26 Test #7: precice.mapping …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  8: precice.math

8/26 Test #8: precice.math …Child killed***Exception: 0.10 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start  9: precice.mesh

9/26 Test #9: precice.mesh …Child killed***Exception: 0.10 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 10: precice.partition

10/26 Test #10: precice.partition …Child killed***Exception: 0.10 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 11: precice.interface

11/26 Test #11: precice.interface …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 12: precice.serial

12/26 Test #12: precice.serial …Child killed***Exception: 0.12 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 13: precice.parallel

13/26 Test #13: precice.parallel …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 14: precice.query

14/26 Test #14: precice.query …Child killed***Exception: 0.12 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 15: precice.testing

15/26 Test #15: precice.testing …Child killed***Exception: 0.12 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 16: precice.utils

16/26 Test #16: precice.utils …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 17: precice.xml

17/26 Test #17: precice.xml …Child killed***Exception: 0.11 sec
dyld: lazy symbol binding failed: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

dyld: Symbol not found: _opal_libevent2022_event_base_loop
Referenced from: /opt/openmpi-3.1.5/bin/mpiexec
Expected in: flat namespace

  Start 18: precice.solverdummy.build.cpp

18/26 Test #18: precice.solverdummy.build.cpp … Passed 0.93 sec
Start 19: precice.solverdummy.build.c
19/26 Test #19: precice.solverdummy.build.c … Passed 0.29 sec
Start 20: precice.solverdummy.build.fortran
20/26 Test #20: precice.solverdummy.build.fortran … Passed 0.43 sec
Start 21: precice.solverdummy.run.cpp-cpp
21/26 Test #21: precice.solverdummy.run.cpp-cpp … Passed 0.51 sec
Start 22: precice.solverdummy.run.c-c
22/26 Test #22: precice.solverdummy.run.c-c … Passed 0.45 sec
Start 23: precice.solverdummy.run.fortran-fortran
23/26 Test #23: precice.solverdummy.run.fortran-fortran … Passed 0.49 sec
Start 24: precice.solverdummy.run.cpp-c
24/26 Test #24: precice.solverdummy.run.cpp-c … Passed 0.46 sec
Start 25: precice.solverdummy.run.cpp-fortran
25/26 Test #25: precice.solverdummy.run.cpp-fortran … Passed 0.45 sec
Start 26: precice.solverdummy.run.c-fortran
26/26 Test #26: precice.solverdummy.run.c-fortran … Passed 0.46 sec

35% tests passed, 17 tests failed out of 26

Label Time Summary:
Solverdummy = 4.46 sec*proc (9 tests)

Total Test time (real) = 6.42 sec

The following tests FAILED:
1 - precice.acceleration (Child killed)
2 - precice.action (Child killed)
3 - precice.com (Child killed)
4 - precice.cplscheme (Child killed)
5 - precice.io (Child killed)
6 - precice.m2n (Child killed)
7 - precice.mapping (Child killed)
8 - precice.math (Child killed)
9 - precice.mesh (Child killed)
10 - precice.partition (Child killed)
11 - precice.interface (Child killed)
12 - precice.serial (Child killed)
13 - precice.parallel (Child killed)
14 - precice.query (Child killed)
15 - precice.testing (Child killed)
16 - precice.utils (Child killed)
17 - precice.xml (Child killed)
Errors while running CTest

I think the problem is that open-mpi links to different version. During tests, it tries to link to 3.1 version while you compile with 4.0.5. If you have installed open-mpi using brew, could you try to extend your library path as:
export PATH=/usr/local/Cellar/open-mpi/4.0.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/Cellar/open-mpi/4.0.5/lib:$LD_LIBRARY_PATH
If you have changed your default install path of brew at some point previously, you might need to change the prefix that I gave.
If it does not work, it would help us to locate the error more precisely if you compile with:
make VERBOSE=1

2 Likes

Thank you, @oguzziya, that works. Precise now compiles and passes all tests as long as you use “cmake … -DBUILD_SHARED_LIBS=ON” (i.e. MPI and PETSc enabled).

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.