Problem with FEniCS on Ubuntu 18.04.1 LTS + Spyder + Python 3

19 days ago by
K D  
I've been running FEniCS on a Windows machine in the following way.  These steps worked for me without any issues at all (I don't have a deep understanding of what I was doing; I simply followed instructions to get FEniCS running).
1. "Windows Subsystem for Linux" to run Ubuntu
2. Followed these instructions to get Python (3.5.2) and Spyder3 (2.3.8):
3. FEniCS following the Ubuntu instructions here:

I recently converted a laptop entirely to Ubuntu 18.04.1 (no Windows or anything else).  I assumed that this would be easier and cleaner to install FEniCS, and maybe faster to run.  I followed essentially the instructions in steps 2 and 3 above.  However, with the default Python 3.6.5, I get the following error:
ModuleNotFoundError: No module named 'fenics'
If I switch Spyder to Python 2.7.15rc1, fenics works fine.  But this is not a real solution for me, because then I get the following error when I try to load scipy:
ImportError: no module named scipy

Ideally, I would like to run FEniCS in Python 3.  Any help is appreciated!  Thanks.
Community: FEniCS Project
Just wanted to add that the install has worked fine on multiple windows machines.
written 19 days ago by K D  

1 Answer

16 days ago by
Potentially 2 separate issues here.  First, do you have the FEniCS packages installed?  What does dpkg -l *dolfin* say?

Secondly, are the python modules accessible? (they should be installed by the packages).  What is returned by
python3 -c "import dolfin; print(dolfin.__version__)"   ?

Note that scipy is a separate package. FEniCS does not depend on it. You'll need to install it separately if you want it.
Hello Drew,

Thanks for responding.  I figured out the scipy issue and can run Fenics (2017.2.0) in Python2.  But I'd like to be running the latest version of Fenics to get the updates and other features going forward, and that requires Python3.  I tried a couple of things that did not work:

1. I have spyder installed and it defaults to python3.  However, when I use a terminal and python -- version, the system default version is python2.
2. So when I run pip install fenics, it complains that it needs python 3.5 (I have fenics for python 2 installed using apt install fenics)
3. When I run pip3 install fenics, it does seem to install it: when I go to ~/.local/lib/python3.6/site-packages, I can find a bunch of directories with fenics in the name.
4. However, when I run python3 (either through spyder or from the command line in a terminal), I get the same ModuleNotFoundError.

I've pasted below the results of the commands from your post

~$ dpkg -l *dolfin*

| 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 2017.2.0.post0-2 all Executable scripts for DOLFIN
ii dolfin-doc 2017.2.0.post0-2 all Documentation and demo programs for DOLFIN
ii libdolfin-dev 2017.2.0.post0-2 amd64 Shared links and 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 libdolfin2017.2 2017.2.0.post0-2 amd64 Shared libraries for DOLFIN
ii python-dolfin 2017.2.0.post0-2 amd64 Python interface for DOLFIN (Python 2)
un python3-dolfin <none> <none> (no description available)

~$ python3 -c "import dolfin; print(dolfin.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'dolfin'

~$ python2 -c "import dolfin; print(dolfin.__version__)"
written 14 days ago by K D  
You haven't installed python3-dolfin yet.
written 14 days ago by Drew Parsons  
I'm aware of that.  My question is *how* to install dolfin.  pip3 install fenics runs without errors but it doesn't seem to be recognized by python3.
written 14 days ago by K D  
Use the Debian or Ubuntu package manager to install packages. apt from the command line, or use the graphical tool. Don't use pip.

sudo apt-get install python3-dolfin
written 14 days ago by Drew Parsons  
Thanks very much -- this worked!  I now have fenics on python3. 

The one issue is that it is the old version of fenics (2017.2.0).  I guess that this uses the Ubuntu package database, and not the FEniCS PPA, and it's a matter of time for the new version to show up in the Ubuntu package database.
written 13 days ago by K D  
2018.1 is available now on Debian. It will transfer over automatically to Ubuntu cosmic (there is currently a problem with the Ubuntu build arising from PETSc). We'll update to 2018.1 in the PPA soon for Ubuntu bionic.

edit: 2018.1 is now available from the PPA for bionic
written 13 days ago by Drew Parsons  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »