Installing python-bindings, preCICE is looking at /usr/local

I am just starting with Precice, trying to use its python bindings, especially with the elastic tube tutorial.

I installed the dependencies through Homebrew, built and installed from source, I updated the env and path variables (using the default option like in here) and Precice is now installed on ~/software/precice/

  • preCICE version 2.5.0
  • MacOs Monterey 12.0.1 (M1)
  • Installed the dependecies with Homebrew (except MPI and PETSc), built and installed from source using cmake.
  • clang version 13.0.0.
  • python 3.8.9

When I run the fluid solver for the tutorial I get the following error :

Traceback (most recent call last):
  File "./", line 12, in <module>
    import precice
  File "~/Library/Python/3.8/lib/python/site-packages/precice/", line 4, in <module>
    from cyprecice import Interface, action_read_iteration_checkpoint, action_write_iteration_checkpoint, action_write_initial_data, get_version_information
ImportError: dlopen(~ /Library/Python/3.8/lib/python/site-packages/, 0x0002): Library not loaded: @rpath/libprecice.2.dylib
  Referenced from: ~/Library/Python/3.8/lib/python/site-packages/
  Reason: tried: '/usr/local/lib/libprecice.2.dylib' (no such file), '/usr/lib/libprecice.2.dylib' (no such file)

So i guess python is looking in /usr/local/lib instead of ~/software/precice/lib. What did I do wrong ?

PS :
echo $PRECICE_PREFIX gives




Thank you in advance.

How did you install the Python bindings? I assume that you installed them from PyPI (with pip3 install --user pyprecice), which would probably assume that preCICE is installed globally on your system.

You probably set your variables based on this note, but I would guess you need to build the Python bindings from source, by cloning the repository and running pip3 install --user ., as stated before the note.

Thank you for your reply. I did installed with pip3, my bad. I now built from source and Apparently Precice can’t be found (?) :

Processing ~/Downloads/python-bindings-python-bindings-v2.5.0.0
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in ~/Library/Python/3.8/lib/python/site-packages (from pyprecice===python-bindings-v2.5.0.0) (1.22.4)
Requirement already satisfied: mpi4py in ~/Library/Python/3.8/lib/python/site-packages (from pyprecice===python-bindings-v2.5.0.0) (3.1.3)
Building wheels for collected packages: pyprecice
  Building wheel for pyprecice (pyproject.toml) ... done
  Created wheel for pyprecice: filename=pyprecice-python_bindings_v2.5.0.0-py2.py3-none-any.whl size=95107 sha256=4fd64c1bc2f7e0f10e035808d2f560236b45d66628a78bda56451a6792e45ef9
  Stored in directory: ~/Library/Caches/pip/wheels/1a/e5/3c/a34c8786dd4f3b28527e5540d44389b2bf677d2be2b6d97198
  WARNING: Built wheel for pyprecice is invalid: Metadata 1.2 mandates PEP 440 version, but 'python-bindings-v2.5.0.0' is not
Failed to build pyprecice
ERROR: Could not build wheels for pyprecice, which is required to install pyproject.toml-based projects

preCICE is installed though(I note that the make test_install passes the test), and the variables are set as :


Hi @PreGMjr

Firstly moving to building the python-bindings from source rather than directly via pip is a good idea. Let us check some basic Python related things on your system. Can you check if you are using a pretty latest version of Python? It need not be the most latest one but at least as latest as possible. Updating Python will also update the setuptools library which handles the installation, so this might give us more clues on what is going on. Also, which command are you actually running for building the package? Do you still use pip or are you trying to build directly from I believe some output is being truncated, can you try to rebuild but with a verbose flag?