I am using debian stretch. I installed fenics from debian stretch’s apt repository, so the installed version of fenics is 1:2016.2.0.1. Yes a bit outdated, but I will just run a simple Poisson equation to play with fenics.
I open a jupyter notebook (which is using Python3) and as the first command I type:
from fenics import *
But I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-23499d756b21> in <module>
----> 1 from fenics import *
ImportError: No module named 'fenics'
On the terminal, the following command does not return any errors:
python2 -c 'import fenics'
So, I believe fenics is properly installed on my system. And the only problem seems to import it into python3.
Therefore the question is this: How can I import the fenics, as the version I have on my operating system, into a python3 jupyter notebook?
Thanks for the tip.
However, I do not understand why I should install docker. Can’t I use fenics without docker? I am averse of installing more-than-necessary packages to my OS.
Yeah, I can do that.
The reason I didn’t do it to begin with was that I didn’t want to install packages from outside debian repos.
It seems like there is no way to use fenics package as is given in the official debian stretch repos…
The version of fenics there is (1:2017.2.0.1) and on its description page it still says “dep: python-instant; simple inlining of C/C++ code in Python 2”.
So, does that mean one cannot import the fenics as is given in the ubuntu repo (without PPA) to a python3 environment, too?
====================
All my pain is this: I just want to be able use the fenics package in a python3 environment as given in official repo of debian. Without docker. Without PPA.
All FEniCS versions >=2017.1.0 can be imported to Python3 according to documentation (See ChangeLog). Personally though I have only installed and checked versions >=2018.1.0 from the debian repo (although since I’m on Ubuntu, I could just use apt install and it worked just fine).
Just FYI, in 2017.1.0 (the version you were trying) parts of it were still to be ported to Python3 - The instant wrapper was one such older library which was decided to be deprecated and hence wasn’t ported. I’d suggest you install the Python2 dependencies and check, and if it still doesn’t work, try a newer version.
HARDER yet definitely possible solution : Build from source.
Hello, did you solve this problem? I am having this same problem. I am trying to use fenics on Ubuntu 18.04, python 3.7.
Fenics is properly installed, still it cannot import module.
Please post the solution if you have solved this.
I am running FEniCS on Ubuntu 18.04 installed from the official repositories with Python 3.6.8 inside a Jupyter Notebook. Maybe you try to import fenics and not dolfin?
You say your installation has python 3.7, and I think Ubuntu 18.04 is one of the latest ubuntu distros so that it should also use python3 as default python.
Can you perhaps write the error message you are getting, along with a screenshot of your jupyter notebook?