# Unable to find Petsc library after ubuntu installation

**URL:** <https://fenicsproject.discourse.group/t/unable-to-find-petsc-library-after-ubuntu-installation/16886>\
**Category:** installation\
**Created:** [January 30, 2025, 3:36pm UTC](https://fenicsproject.discourse.group/t/unable-to-find-petsc-library-after-ubuntu-installation/16886 "2025-01-30T15:36:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbpiper](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kbpiper](https://fenicsproject.discourse.group/u/kbpiper)\
**Post date:** [January 30, 2025, 3:36pm UTC](https://fenicsproject.discourse.group/t/unable-to-find-petsc-library-after-ubuntu-installation/16886/1 "2025-01-30T15:36:40Z")

</div>

Attempting to run demo\_poisson after apt-install in Ubuntu with WSL. It seems necessary packages didn’t install? I receive this error, and am not sure where to start troubleshooting

```auto
Traceback (most recent call last):
  File "/home/.../demo_poisson.py", line 70, in <module>
    import dolfinx
  File "/home/.../python3.12/site-packages/dolfinx/ __init__.py", line 32, in <module>
    from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot, utils
  File "/home/.../python3.12/site-packages/dolfinx/utils.py", line 115, in <module>
    class ctypes_utils:
  File "/home/.../python3.12/site-packages/dolfinx/utils.py", line 136, in ctypes_utils
    _lib_ctypes = _ctypes.cdll.LoadLibrary(str(get_petsc_lib()))
                                               ^^^^^^^^^^^^^^^
  File "/home/.../python3.12/site-packages/dolfinx/utils.py", line 44, in get_petsc_lib
    raise RuntimeError(
RuntimeError: Could not find a PETSc shared library. Candidate paths: ['/tmp/pip-build-env-7rtr6ii0/normal/lib/python3.12/site-packages/petsc/lib/libpetsc.so', '/tmp/pip-build-env-7rtr6ii0/normal/lib/python3.12/site-packages/petsc/lib/libpetsc.dylib']

```

---

<div class="post-metadata">

**Author:** ![dparsons](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dparsons](https://fenicsproject.discourse.group/u/dparsons)\
**Post date:** [January 31, 2025, 12:43am UTC](https://fenicsproject.discourse.group/t/unable-to-find-petsc-library-after-ubuntu-installation/16886/2 "2025-01-31T00:43:33Z")

</div>

> [@kbpiper](#):
>
> `File "/home/.../python3.12/site-packages/dolfinx/ __init__.py"`

Your error message references `/home`. It looks like you haven’t used apt to install dolfinx.

---

<div class="post-metadata">

**Author:** ![kbpiper](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kbpiper](https://fenicsproject.discourse.group/u/kbpiper)\
**Post date:** [January 31, 2025, 2:58am UTC](https://fenicsproject.discourse.group/t/unable-to-find-petsc-library-after-ubuntu-installation/16886/3 "2025-01-31T02:58:12Z")

</div>

Just to be sure, I uninstalled and reinstalled, definitely using apt.  
When I type `whereis dolfinx` I get `dolfinx: /usr/local/lib/dolfinx /usr/include/dolfinx /usr/share/dolfinx`. when I type `whereis python3`, I get `python3: /usr/bin/python3 /usr/lib/python3 /etc/python3 /usr/share/python3`. `/home` is still showing up in the error traceback when I run `demo_poisson` though.

Edit for anyone who comes across this in the future - I somehow had a second installation of python in /home. Removing that instance fixed the issue
