# Fenics from pip

**URL:** <https://fenicsproject.discourse.group/t/fenics-from-pip/4287>\
**Category:** installation\
**Created:** [October 9, 2020, 5:16pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287 "2020-10-09T17:16:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iactor](https://avatars.discourse-cdn.com/v4/letter/i/6f9a4e/32.png) [@Iactor](https://fenicsproject.discourse.group/u/Iactor)\
**Post date:** [October 9, 2020, 5:16pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/1 "2020-10-09T17:16:37Z")

</div>

Hi,  
I just saw that fenics is registerd on PyPi [https://pypi.org/project/fenics/](https://pypi.org/project/fenics/) which would make installation much more simple via pip.  
However this possibility is not even mentioned on the project webpage (something I find strange) and installation via pip does not install dolfin (FFC, FIAT, dijitso, and ufl seem to be installed correctly).  
Does anyone know the reason for this behaviour and if it is likely to be fixed soon?  
Installing via pip would be great expecially for unexperienced users.  
Thanks.  
I

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 9, 2020, 5:51pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/2 "2020-10-09T17:51:49Z")

</div>

As dolfin as several no -Python dependencies, as well as a C++ backend, you cannot install it via pip. However, you can Get it from PPA for ubuntu, use docker or conda (experimental)

---

<div class="post-metadata">

**Author:** ![Iactor](https://avatars.discourse-cdn.com/v4/letter/i/6f9a4e/32.png) [@Iactor](https://fenicsproject.discourse.group/u/Iactor)\
**Post date:** [October 9, 2020, 6:16pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/3 "2020-10-09T18:16:04Z")

</div>

Cannot you (as a project not the already too kind dokken) think about a solution at least for people that want to use just the python API?  
I have quite a few python packages based on fenics that I would like to distribute via pypi and the installation would be much smoother if it was possible to download fenics from pip.  
This drawback is by the way a good reason for many users to move to another project as nutils.

---

<div class="post-metadata">

**Author:** ![miguel](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/miguel/32/269_2.png) [@miguel](https://fenicsproject.discourse.group/u/miguel)\
**Post date:** [October 9, 2020, 6:39pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/4 "2020-10-09T18:39:30Z")

</div>

How does nutils handle the linear algebra and the assembly? These are usually the most time consuming operations that are usually handled by either C/C++ libraries or by Just in Time compilation techniques.

---

<div class="post-metadata">

**Author:** ![Iactor](https://avatars.discourse-cdn.com/v4/letter/i/6f9a4e/32.png) [@Iactor](https://fenicsproject.discourse.group/u/Iactor)\
**Post date:** [October 9, 2020, 7:14pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/5 "2020-10-09T19:14:59Z")

</div>

No idea, but I guess they compile part of the code, it cannot be pure python.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 9, 2020, 7:29pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/6 "2020-10-09T19:29:40Z")

</div>

The linear algebra backend most people use (including dolfin and firedrake) is PETSc, PETSc cannot be installed through pip and require alot of extra packages.

I have listed every package fenics requires for ubuntu 20.04 here:

> [@How to install dolfin on Ubuntn-20.04 from source](https://fenicsproject.discourse.group/t/how-to-install-dolfin-on-ubuntn-20-04-from-source/4233/5):
>
> Here is a full step by step dockerfile for installing dolfin in ubuntu 20.04. One should simply be able to copy-paste each of the commands (stripping them of docker syntax), or build a corresponding dockerimage by saving this as Dockerfile and run docker build -t dolfinimage . FROM ubuntu:20.04 as dolfinsrc ARG PYBIND11\_VERSION=2.5.0 ARG PETSC\_VERSION=3.13.3 ARG SLEPC\_VERSION=3.13.3 ARG PETSC4PY\_VERSION=3.13.0 ARG SLEPC4PY\_VERSION=3.13.0 # Flags to pass to ninja build system. ARG MAKEFLAGS # …

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 9, 2020, 7:31pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/7 "2020-10-09T19:31:38Z")

</div>

Also note that the Python interface of dolfin is basically a wrapper around C++ to make it friendly.  
The core classes such as meshes, functionspaces, dofmaps etc are defined in C++ and just binded to Python

---

<div class="post-metadata">

**Author:** ![Iactor](https://avatars.discourse-cdn.com/v4/letter/i/6f9a4e/32.png) [@Iactor](https://fenicsproject.discourse.group/u/Iactor)\
**Post date:** [October 9, 2020, 8:54pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/8 "2020-10-09T20:54:12Z")

</div>

Fine. If there is no other way I will share my code putting a link to the fenics installation page.

---

<div class="post-metadata">

**Author:** ![Thomas2](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@Thomas2](https://fenicsproject.discourse.group/u/Thomas2)\
**Post date:** [October 12, 2020, 12:14pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/9 "2020-10-12T12:14:05Z")

</div>

Hi Dokken

petsc can be installed now from pip (not sure when it started but its since at least a year)

it works well with fenics (on debian 10 at least)

sudo pip3 -E install petsc slepc slepc4py petsc4py

this has always worked flawlessly for me you can change the PETSC\_CONFIGURE\_OPTIONS to get different variations - eg this is what I am using  
export PETSC\_CONFIGURE\_OPTIONS=’–download-mumps=1 --download-openblas=1 --download-scalapack=1 --download-hypre=1 --download-suitesparse=1 --download-ptscotch=1 ’

I usually remove the distribution petsc first but in theory you can get them to coexist - I think sudo pip -E is not recommended , pipenv is probably better - but I never had the time to try it

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 12, 2020, 12:18pm UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/10 "2020-10-12T12:18:00Z")

</div>

Thats good news. People are of course free to package dolfin as a pypi package, and make a pull request to the dolfin bitbucket repository. I do not have the bandwidth to do this packaging,maintenance and bug-fixing.

---

<div class="post-metadata">

**Author:** ![xiaohe](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/xiaohe/32/7777_2.png) [@xiaohe](https://fenicsproject.discourse.group/u/xiaohe)\
**Post date:** [May 23, 2023, 8:30am UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/11 "2023-05-23T08:30:22Z")

</div>

Hello, i am working which need to use FEM(in fenics) and PINNs(in pytorch). If fenics can be installed by pip , my work can go on. Can you show the installation process. Or, is there any way to solution my work.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 23, 2023, 8:36am UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/12 "2023-05-23T08:36:07Z")

</div>

I would suggest using `conda` if you are working with legacy FEniCS.

---

<div class="post-metadata">

**Author:** ![xiaohe](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/xiaohe/32/7777_2.png) [@xiaohe](https://fenicsproject.discourse.group/u/xiaohe)\
**Post date:** [May 24, 2023, 4:53am UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/13 "2023-05-24T04:53:40Z")

</div>

But my computer system is windows.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 24, 2023, 4:56am UTC](https://fenicsproject.discourse.group/t/fenics-from-pip/4287/14 "2023-05-24T04:56:04Z")

</div>

Then you should use docker. dolfin relies on PETSc, which is tricky to install on windows.
