importing petsc4py fails in 22.04

Bug #1980878 reported by Christophe Prud'homme
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
petsc4py (Ubuntu)
New
Undecided
Unassigned

Bug Description

petsc4py cannot be used out of the box in python

install petsc4py
> apt install python3-petsc4py-real3.15 python3-petsc4py python3-petsc4py-real

then do
> python3 -c "import petsc4py"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'petsc4py'

to make it work you need to do :
> python3 -c "import sys;sys.path.append('/usr/lib/petscdir/petsc3.15/x86_64-linux-gnu-real/lib/python3/dist-packages'); import petsc4py"

then all good

an alternative is to install eg libpetsc64-real-dev
this will then configure the python path for petsc4py

Revision history for this message
Christophe Prud'homme (prudhomm-debian) wrote :

I am probably missing something here. I would be very happy to learn what.
I understand that we can switch between real/complex and 32/64 indexing but still there should be a way to configure alternatives at least no?

Revision history for this message
Christophe Prud'homme (prudhomm-debian) wrote :

None of the explanations to run petsc4py in /usr/share/doc/python3-petsc4py/README.Debian work by simply installing python3-petsc4py-real and python3-petsc4py

what works is to set by hand PETSC_DIR, there should be a default alternative, IMHO

> PETSC_DIR=/usr/lib/petscdir/petsc3.15/x86_64-linux-gnu-real python3 -c "import petsc4py; print(petsc4py.__path__)"
['/usr/lib/petscdir/petsc3.15/x86_64-linux-gnu-real/lib/python3/dist-packages/petsc4py']

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.