Hi there! I am facing a problem that I haven’t yet encountered. Any suggestions would be much appreciated.
Previously, I successfully executed a number of codes with the following starting commands:
from dolfin import *
import meshio
from dolfin import Mesh, XDMFFile, File, MeshValueCollection, cpp
However, today when I tried to execute the same codes that I successfully executed before, I encountered the following error message:
Traceback (most recent call last):
File "cuboidtest1.py", line 1, in <module>
from dolfin import *
ModuleNotFoundError: No module named 'dolfin'
Since I access FEniCS from my university server (which many people access), I thought FEniCS has been uninstalled from the server. But upon further checking with the code dolfin-version
, I found the version 2019.2.0. still there.
I am totally confused and don’t know what to do.
Any help or suggestion would be much appreciated.
That error can occur when there is a version mismatch, or a packaging error. It occured recently in the version provided by the FEniCS PPA from https://launchpad.net/~fenics-packages/+archive/ubuntu/fenics, which should be now fixed. If your university updated to the recent PPA but before the final fix then you might encounter the error. Version mismatch can also occur if a local version was installed manually using pip. It depends on how your dolfin package was installed.
You can help pin down the problem with some version checks. Assuming you’re using Ubuntu, what do these commands return?
$ lsb_release -a
$ python3 --version
$ dpkg -l *dolfin* | cat
$ dpkg -l *petsc* | cat
$ ls ~/.local/lib/python3*/site-packages/
1 Like
More background context (skip if this comment doesn’t make sense): because of the tight dependency between dolfin, python and petsc, the dolfin python module is now installed by recent Debian/Ubuntu packaging under the relevant PETSC_DIR (see /usr/lib/petsc, or under /usr/lib/petscdir) rather than directly in the system PYTHONPATH. dolfin.pth is placed in the system PYTHONPATH and redirects to the appropriate PETSC_DIR. If the location of PETSC_DIR deviates from the default value (/usr/lib/petsc) then you might get the No module named 'dolfin'
error, since dolfin.pth doesn’t know where to direct. If a dolfin module is installed under a specific PETSC_DIR different from the default path, then you might have success setting PETSC_DIR as an environment variable before invoking python.
1 Like
Thanks for your response. Here is what the above codes return: I am new to FEniCS. So I didn’t understand the second comment of yours on the background context.
avishmj@math-alfred:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
avishmj@math-alfred:~$ python3 --version
Python 3.8.5
avishmj@math-alfred:~$ dpkg -l *dolfin* | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================-==========================================-============-=============================================
ii dolfin-bin 2019.2.0~git20201207.b495043-4~ppa1~focal4 all Executable scripts for DOLFIN
ii dolfin-doc 2019.2.0~git20201207.b495043-4~ppa1~focal4 all Documentation and demo programs for DOLFIN
ii libdolfin-dev:amd64 2019.2.0~git20201207.b495043-4~ppa1~focal4 amd64 Shared links and development files for DOLFIN
ii libdolfin-dev-common 2019.2.0~git20201207.b495043-4~ppa1~focal4 all Common header files for DOLFIN
un libdolfin0-dev <none> <none> (no description available)
un libdolfin1.0-dev <none> <none> (no description available)
un libdolfin1.1-dev <none> <none> (no description available)
un libdolfin1.2-dev <none> <none> (no description available)
un libdolfin1.3-dev <none> <none> (no description available)
un libdolfin1.4-dev <none> <none> (no description available)
ii libdolfin2019.2:amd64 2019.2.0~git20201207.b495043-4~ppa1~focal4 amd64 Shared libraries for DOLFIN
ii python3-dolfin 2019.2.0~git20201207.b495043-4~ppa1~focal4 amd64 Base Python interface for DOLFIN (Python 3)
ii python3-dolfin-real 2019.2.0~git20201207.b495043-4~ppa1~focal4 amd64 Python interface for DOLFIN
un python3-dolfin64-real <none> <none> (no description available)
avishmj@math-alfred:~$ dpkg -l *petsc* | cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===========================-==============-============-======================================================
un libpetsc-complex-3.6.2-dev <none> <none> (no description available)
un libpetsc-complex-3.6.3-dev <none> <none> (no description available)
un libpetsc-complex3.12-dev <none> <none> (no description available)
ii libpetsc-real3.12:amd64 3.12.4+dfsg1-1 amd64 Shared libraries for version 3.12 of PETSc
un libpetsc-real3.12-dbg <none> <none> (no description available)
ii libpetsc-real3.12-dev:amd64 3.12.4+dfsg1-1 amd64 Static libraries, shared links, header files for PETSc
un libpetsc3.12 <none> <none> (no description available)
ii libpetsc3.12-dev-common 3.12.4+dfsg1-1 all Common header and support dev files for PETSc
un libpetsc3.12-dev-examples <none> <none> (no description available)
un libpetsc3.12.4-dev <none> <none> (no description available)
un libpetsc3.6 <none> <none> (no description available)
un libpetsc3.6.2-dev <none> <none> (no description available)
un libpetsc3.6.3-dev <none> <none> (no description available)
un petsc-dev <none> <none> (no description available)
un petsc3.12-doc <none> <none> (no description available)
un python-petsc4py-doc <none> <none> (no description available)
ii python3-petsc4py 3.12.0-4build1 all Python 3 bindings for PETSc libraries
un python3-petsc4py-complex <none> <none> (no description available)
ii python3-petsc4py-real 3.12.0-4build1 amd64 Python 3 bindings for PETSc libraries (real numbers)
avishmj@math-alfred:~$ ls ~/.local/lib/python3*/site-packages/
h5py meshio-4.3.10.dist-info versioned_hdf5
h5py-2.10.0.dist-info ndindex versioned_hdf5-1.2.3.dist-info
meshio ndindex-1.5.1.dist-info
Hi dparsons! I solved the problem. Thanks for your feedback!
Yes, your university did catch the broken version (~focal4
). That was very efficient of them, it was only available a few days. The fixed version is ~focal5
. Likely your university’s next update will catch the fixed version soon if they haven’t already.
Anyway, glad you got it working.
1 Like
Hi dparsons!
I posted another problem @ Mesh in FEniCS vs mesh in gmsh
If you find some time and if you want, can you take a look at it?
That mesh problem looks like a coding or API problem, not a packaging or installation problem.
Yes, you’re right. It’s coding problem.