Python-Bindings on server

Hello,

I’m installing preCICE on a server where I have to install everything with source packages.
I succesfully installed preCICE but now it seems that I cannot install the Python-bindings.
The error I get after installation is:

$ python3 -c "import precice"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/zanella/softwares/python-bindings-2.2.0.1/precice/__init__.py", line 3, in <module>
    from cyprecice import Interface, action_read_iteration_checkpoint, action_write_iteration_checkpoint, action_write_initial_data, get_version_information
ImportError: /home/zanella/.local/lib/python3.9/site-packages/pyprecice-2.2.0.1-py3.9-linux-x86_64.egg/cyprecice.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNK7precice15SolverInterface9getMeshIDERKSs

Can anyone help me to understand this?

Could you check what is the content of the environment variable LD_LIBRARY_PATH? You can check this with echo LD_LIBRARY_PATH.

If preCICE lib directory is not in there, could you try setting it with
export LD_LIBRARY_PATH=YOURPATHTOPRECICE/lib:${LD_LIBRARY_PATH} and test again? Obviously, you need to replace YOURPATHTOPRECICE with the actual path to where you have installed preCICE.

Among the other library paths, I also have /home/zanella/softwares/precice/lib:, which I think is the correct one.

That sounds good so far. Are you still in the directory /home/zanella/softwares/python-bindings-2.2.0.1 when testing the bindings? Could you open a new terminal and/or go to a different directory, e.g. /home/zanella, and try running python3 -c "import precice" again?

If this does not work the output of ls /home/zanella/softwares/precice/lib and ldd /home/zanella/.local/lib/python3.9/site-packages/pyprecice-2.2.0.1-py3.9-linux-x86_64.egg/cyprecice.cpython-39-x86_64-linux-gnu.so would be interesting.

This doesn’t work. It displays the same message as above.

output:

cmake  libprecice.so  libprecice.so.2  libprecice.so.2.2.0  pkgconfig

output:
ldd_output.txt (3.6 KB)

That is weird. Is /home/zanella/softwares/precice/lib the only preCICE library in your path? You could also check for the symbols in your preCICE library with and there specifically the one not found. Running the following command should give you some nonempty output

nm -D /home/zanella/softwares/precice/lib/libprecice.so.2 | grep precice15SolverInterface9getMesh

Yes, nonempty indeed:

0000000000314c50 T _ZNK7precice15SolverInterface9getMeshIDERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

This is interesting. This is indeed not the symbol the Python bindings are looking for…
The bindings look for

_ZNK7precice15SolverInterface9getMeshIDERKSs

while your library has

_ZNK7precice15SolverInterface9getMeshIDERKNSt7

I cut off some part for better readability. I would suggest to uninstall the Python bindings and then to reinstall them again. Pay attention to what library the bindings are linking to and keep the output of the compilation process of the Python bindings. This will make debugging easier.

Thank you, I’ll try this and then I’ll let you know.
One question, though: is there any way to correctly remove all folders created by the python-bindings installation? For example the folder in Python3.9. Should I remove them manually?
Regarding the fact that my precice installation is in a custom chosen folder, is this the correct way to build the python-bindings?

python3 setup.py build_ext --include-dirs=/home/zanella/softwares/precice/include --library-dirs=/home/zanella/softwares/precice/lib

I would think that you could uninstall it with

pip3 uninstall pyprecice

or

pip3 uninstall --user pyprecice

Alternatively, I would assume that removing the corresponding directories and files in /home/zanella/.local/lib/python3.9/site-packages, but I am no expert in this.

The preCICE bindings should pick up your custom location if the necessary environment variables are set correctly. If that does not work you could set additional paths as mentioned in the README or to use the setup.py as mentioned by you. I normally install the bindings using pip/pip3. I have not used the setup.py directly in a while.

Hi,

just copying the relevant issue from the python-bindings repository to link it to the discussion here.

I just wanted to add here that one can use pip on a server without admin right as well using the --user flag when installing the package. One can even clone the code from the GitHub repository and build and install it using pip/pip3 as described in the bindings’ documentation.

1 Like

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