This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Trouble importing dolfin on Ubuntu 14.04

0 votes

I am running Ubuntu 14.04, and python 2.7.6, and have had trouble running importing DOLFIN. I used the following commands to install, as suggested by FENiCS documentation:

sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install fenics
sudo apt-get dist-upgrade

No errors occurred during installation, but when running the command

from dolfin import *

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/dolfin/__init__.py", line 16, in <module>
    from . import cpp
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp/__init__.py", line 42, in <module>
    exec("from . import %s" % module_name)
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp/function.py", line 209, in <module>
    class GenericFunction(ufc.function, common.Variable):
AttributeError: 'module' object has no attribute 'function'

Any help would be greatly appreciated. Thanks!

asked Aug 17, 2016 by rizii FEniCS Novice (170 points)

What is the output of dpkg -l | grep "~ppa"?

ii  dolfin-bin                                            1.6.0-1~ppa1~trusty1                                all          Executable scripts for DOLFIN
ii  dolfin-doc                                            1.6.0-1~ppa1~trusty1                                all          Documentation and demo programs for DOLFIN
ii  fenics                                                1:1.6.0.1~ppa1~trusty1                              all          Automated Solution of Differential Equations
ii  libdolfin-dev                                         1.6.0-1~ppa1~trusty1                                amd64        Shared links and header files for DOLFIN
ii  libdolfin1.6                                          1.6.0-1~ppa1~trusty1                                amd64        Shared libraries for DOLFIN
ii  libmshr-dev                                           1.6.0-1~ppa1~trusty3                                amd64        Shared links and header files for mshr
ii  libmshr1.6                                            1.6.0-1~ppa1~trusty3                                amd64        Shared libraries for mshr
ii  mshr-demos                                            1.6.0-1~ppa1~trusty3                                all          Examples and demo programs for mshr
ii  python-dolfin                                         1.6.0-1~ppa1~trusty1                                amd64        Python interface for DOLFIN
ii  python-ffc                                            2016.1.0-1~ppa1~trusty1                             amd64        compiler for finite element variational forms
ii  python-fiat                                           2016.1.0-1~ppa1~trusty1                             all          tabulation of finite element function spaces
ii  python-instant                                        2016.1.0-1~ppa1~trusty1                             all          simple inlining of C / C++ code in Python
ii  python-mshr                                           1.6.0-1~ppa1~trusty3                                amd64        Python interface for mshr
ii  python-petsc4py                                       3.4-1~ppa1~trusty1                                  amd64        Python bindings for PETSc libraries
ii  python-ufl                                            2016.1.0-1~ppa1~trusty1                             all          unified language for form-compilers
ii  python-ufl-doc                                        2016.1.0-1~ppa1~trusty1                             all          documentation and demos for UFL
ii  python-uflacs                                         1.6.0+dfsg-1~ppa1~trusty1                           all          UFL Analyser and Compiler System
ii  swig3.0                                               3.0.5-1~ppa1~trusty1                                amd64        Generate scripting interfaces to C/C++ code

Only version 1.6.0 is available for Ubuntu 14.04. How did you install the 2016.1.0-1~ppa1-trusty1 packages? AFAIK, these are only available in the FEniCS experimental builds PPA and should not be used. You should remove them and install the 1.6.0 packages instead. Alternatively, you can upgrade to Ubuntu 16.04 if you want to install the latest FEniCS version from the FEniCS PPA.

Thanks johannr, this fixed the problem.

In my /etc/apt/sources.list.d/fenics-packages-fenics-trust.list file, I had this line for some reason:

deb http://ppa.launchpad.net/fenics-packages/fenics-exp/ubuntu trusty main

I manually changed 'fenics-exp' to 'fenics' and reinstalled, and fenics runs smoothly now.

Thank you, again!

...