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

How to use FEniCS in Jupyter Notebook or Spyder?

+1 vote

I have recently installed FEniCS using Docker with following command

Terminal> curl -s https://get.fenicsproject.org | bash

Every thing works well when I am in fenicsproject session. In this session when I use which python I get the following

   fenics@7016ac685f58:~$ which python
   /usr/bin/python

However, when I try to use the following command in Jupyter Notebook

from fenics import *

I get the following error

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-66a9e72f2de9> in <module>()
      2 # Poisson solver in Python using FEniCS
      3 # import FEniCS
----> 4 from fenics import *
      5 #
      6 # create mesh and denfine functional space

ImportError: No module named fenics

I am using Python provided by anaconda, details about the python are given given below

Python 2.7.12 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:43:17) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

and which python gives me following path

h147:project0 vikas$ which python
/Users/vikas/anaconda/bin/python

I dont know how to solve this problem. Please help me.

asked Feb 4, 2017 by vickysharma0812 FEniCS Novice (130 points)

2 Answers

+1 vote

You probably want to use the FEniCS packages for Conda instead of the Docker images. See https://github.com/conda-forge/fenics-feedstock/.

answered Feb 6, 2017 by johannr FEniCS Expert (17,350 points)
+1 vote

You probably wanted to do

from dolfin import *
answered Feb 12, 2017 by praveen FEniCS User (2,760 points)
...