# Python-Bindings on server

**URL:** <https://precice.discourse.group/t/python-bindings-on-server/612>\
**Category:** Installing preCICE\
**Tags:** python\
**Created:** [May 26, 2021, 2:31pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612 "2021-05-26T14:31:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![alicezanella](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alicezanella/32/589_2.png) [@alicezanella](https://precice.discourse.group/u/alicezanella)\
**Post date:** [May 26, 2021, 2:31pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/1 "2021-05-26T14:31:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 26, 2021, 3:22pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/2 "2021-05-26T15:22:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alicezanella](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alicezanella/32/589_2.png) [@alicezanella](https://precice.discourse.group/u/alicezanella)\
**Post date:** [May 26, 2021, 3:46pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/3 "2021-05-26T15:46:55Z")

</div>

> [@ajaust](#):
>
> Could you check what is the content of the environment variable `LD_LIBRARY_PATH` ? You can check this with `echo LD_LIBRARY_PATH` .

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

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 26, 2021, 3:52pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/4 "2021-05-26T15:52:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alicezanella](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alicezanella/32/589_2.png) [@alicezanella](https://precice.discourse.group/u/alicezanella)\
**Post date:** [May 26, 2021, 3:57pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/5 "2021-05-26T15:57:31Z")

</div>

> [@ajaust](#):
>
> try running `python3 -c "import precice"` again?

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

> [@ajaust](#):
>
> `ls /home/zanella/softwares/precice/lib`

output:

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

```

> [@ajaust](#):
>
> `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`

output:  
[ldd\_output.txt](https://precice.discourse.group/uploads/short-url/bDvxWHQyX1F8gBLXutzHUf3tx6B.txt) (3.6 KB)

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 26, 2021, 4:18pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/6 "2021-05-26T16:18:07Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![alicezanella](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alicezanella/32/589_2.png) [@alicezanella](https://precice.discourse.group/u/alicezanella)\
**Post date:** [May 26, 2021, 4:20pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/7 "2021-05-26T16:20:14Z")

</div>

Yes, nonempty indeed:

```
0000000000314c50 T _ZNK7precice15SolverInterface9getMeshIDERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

```

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 26, 2021, 4:24pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/8 "2021-05-26T16:24:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alicezanella](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/alicezanella/32/589_2.png) [@alicezanella](https://precice.discourse.group/u/alicezanella)\
**Post date:** [May 26, 2021, 4:30pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/9 "2021-05-26T16:30:55Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 26, 2021, 4:42pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/10 "2021-05-26T16:42:40Z")

</div>

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](https://github.com/precice/python-bindings) 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.

---

<div class="post-metadata">

**Author:** ![IshaanDesai](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ishaandesai/32/1048_2.png) [@IshaanDesai](https://precice.discourse.group/u/IshaanDesai)\
**Post date:** [May 27, 2021, 8:35pm UTC](https://precice.discourse.group/t/python-bindings-on-server/612/11 "2021-05-27T20:35:10Z")

</div>

Hi,

just copying the [relevant issue](https://github.com/precice/python-bindings/issues/106) from the `python-bindings` repository to link it to the discussion here.

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [May 28, 2021, 8:23am UTC](https://precice.discourse.group/t/python-bindings-on-server/612/12 "2021-05-28T08:23:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [July 14, 2021, 8:31am UTC](https://precice.discourse.group/t/python-bindings-on-server/612/13 "2021-07-14T08:31:31Z")

</div>

Closed on July 14, 2021, 8:31am UTC

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