How to use FEniCS in Jupyter Notebook or Spyder?

2024/10/14 17:17:03

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 FEniCS3 # import FEniCS
----> 4 from fenics import *5 #6 # create mesh and denfine functional spaceImportError: 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.

Answer

I had the same problem. Something strange happens whenever I use fenics through Anaconda. I deactivated Anaconda and runned the fenics in the system. Worked perfectly.

https://en.xdnf.cn/q/117933.html

Related Q&A

Error installing polyglot in python 3.5.2

I want to do sentiment analysis on urdu sentences. I searched a python package Polyglot having URDU POS tagger in it. But on installing, it prompts error;Any way out?

How do you turn a dict of lists into a list of dicts with all combinations?

Basically what I am looking for is the equivalent of itertools.product but for dicts.For example, say I want to test a function for all combinations of its keyword arguments, I would like to pass lists…

Django differentiate between the first time user and returning user

I am using django registration redux for login and auth purposes. I want to do the following.if the user logs in for the first time i want to redirect to URL-"profile/create" if the user is a…

Automatically cropping an image using Python

I want to automatically crop an image using OpenCV into many images, the number of output images is variable. I started by replacing the white background by a transparent background.The input image: I …

How to find highest product of k elements in an array of n length, where k n

I recently tried the question for the highest product of 3 elements. Now I am trying to do it for the k elements. Lets say from 3 now it is asking for 4 elements. I tried to write a generic function so…

Kivy error - Unable to get a window, abort

I installed kivy on my Raspberry pi3, where i run a python program that already works on another pi3.I now am trying to install the same thing on this second pi, and it doesnt work...maybe I forgot som…

Selenium 3.0.2 error with Firefox 50: executable may have wrong permissions

Im trying to use Selenium 3.0.2 with Firefox 50.0.1 in Windows 7. Ive followed the instructions in this post to setup correctly the driver and the paths but Im getting the following error: Traceback (m…

Convert a jpg to a list of lists

Im trying to figure out how to convert a jpg into a list of lists (using python 3.2.3) such that:[ [red,blue,red,etc..], #line1 [blue,red,yellow, etc...], #line2 [orange,yellow,black,et…

TypeError: No to_python (by-value) converter found for C++ type

Im trying to expose my C++ Classes to Python using Boost.Python. Here is a simplyfied version of what Im trying to do:struct Base {virtual ~Base() {};virtual char const *Hello() {printf("Base.Hell…

USB interface in Python

I have this (http://www.gesytec.de/en/download/easylon/p/16/) USB device connected to my Win7. I am just trying to read the vendor ID and product ID. I have Python 2.7.Here is the code,import usb busse…