conda install -c anaconda fenics-dolfin
For conda installation instructions, please look at https://anaconda.org/conda-forge/fenics.
I always used
conda install -c conda-forge fenics for my installation.
Running your command I get the output
fenics 2019.1.0 py311h38be061_34 conda-forge fenics-dijitso 2019.1.0 py311h38be061_34 conda-forge fenics-dolfin 2019.1.0 py311h0a5b7eb_34 conda-forge fenics-ffc 2019.1.0 py311h38be061_34 conda-forge fenics-fiat 2019.1.0 py311h38be061_34 conda-forge fenics-libdolfin 2019.1.0 h0f808bc_34 conda-forge fenics-ufl 2019.1.0 py311h38be061_34 conda-forge
To check whether FEniCS has been installed properly you can run
python3 -c "import dolfin; print(dolfin.__version__)".
But I think that you might not have correctly installed FEniCS.
Therefore please execute
conda install -c conda-forge fenics in your conda environment.
THanks ! Is "
conda install -c conda-forge fenics" the only command to enable the use of dolfin in python?
No, this is just for the installation, if you use conda. For more information on the installation, please refer to https://fenicsproject.org/download/archive/
Thanks, I have run sudo apt-get install fenics and get “fenics is already the newest version (1:2019.2.0.5~ppa1~bionic1).” After this conda command, what else is needed for use in python? It seems the site only provide such comamnds.
Can you please verify your installation by running
python3 -c "import dolfin; print(dolfin.__version__)" in your terminal? If FEniCS has been installed correctly, this code should work. Otherwise you should get an error message
It shows cannot find module.
Then you haven’t correctly installed FEniCS. I have already described in my previous answers what worked for me. Maybe someone else can help you.
(In the worst case, you can always use FEniCS in Google Colab for smaller projects and there should be no issues with installation: Packages — FEM on Colab)
thanks very much for your help
What is the supported version of Fenics? Does it support python 10 and 11？
Legacy fenics is no longer developed. I believe it works with Python 3.10.
DOLFINx works with Python 3.10 and 3.11.
Previous command “conda install -c conda-forge fenics” installs fenics. I saw your code to generate 1d mesh with a list of vertices idofinx, but it does not work with idofin. How to modify it for dolfin?
from dolfinx.fem import FunctionSpace
from dolfinx.mesh import create_mesh
from mpi4py import MPI
import numpy as np
gdim, shape, degree = 1, “interval”, 1
cell = ufl.Cell(shape, geometric_dimension=gdim)
domain = ufl.Mesh(ufl.VectorElement(“Lagrange”, cell, degree))
x = np.array([, [0.2], [0.6], , [1.3]])
cells = np.array([[0, 1], [1, 2], [2, 3], [3, 4]], dtype=np.int64)
mesh = create_mesh(MPI.COMM_WORLD, cells, x, domain)
V = FunctionSpace(mesh, (“P”, 1))
Please search the forum for such questions, as they have been answered before.
Also, if you choose to use legacy dolfin there is plenty of literature on the subject, including:
The fenics book (2012)
and the fenics tutorial (2016)