Appearance
Installing FEniCS in WSL On Windows
Once your Ubuntu environment is ready, the next step is to install FEniCS, the main solver engine used for running simulations.
We’ll go through the installation process step by step, using the terminal inside your Ubuntu (WSL) environment.
If you prefer following along with a visual walkthrough, you can watch the complete video tutorial below:
Step-1: Update and Upgrade System Packages
Before installing anything, always make sure your package list and system libraries are up to date. Run the following commands in your Ubuntu terminal:
bash
sudo apt update
sudo apt upgrade -yThis ensures that your system has the latest dependencies required for a smooth installation.
Step-2: Add the FEniCS Repository and Install
Next, we’ll add the official FEniCS PPA (Personal Package Archive) to your system and install it.
bash
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:fenics-packages/fenics -y
sudo apt update
sudo apt install fenics -yThis will install the full FEniCS suite — including dolfin, ufl, and all required solver libraries.
For more details, you can also check the official FEniCS documentation here: https://fenicsproject.org/download/archive/
Step-3: Install Python Tools and Libraries
Some Python packages are not included with FEniCS by default, so we’ll install them manually.
bash
sudo apt install python3-pip -y
pip3 install meshio==3.2.7
pip3 install h5py
pip3 install lxmlHere, meshio is essential for converting and handling mesh files between Salome and FEniCS, while h5py and lxml support file I/O and structured data management.
Step-4: Verify the Installation
Once everything is installed, verify that both FEniCS and meshio are working correctly.
bash
python3 -c "import dolfin; print('FEniCS version:', dolfin.__version__)"
python3 -c "import meshio; print('meshio version:', meshio.__version__)"If you see version numbers displayed without errors, your installation is successful.
Step-5: Setting Up Jupyter Notebook
We often use Jupyter Notebooks to run and visualize FEniCS scripts interactively. Install and configure it using the following commands:
bash
pip3 install --user jupyter jupyterlab jupyter-core ipykernel jupyter-client nbconvert ipywidgets nbclient qtconsole
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
pip install --upgrade traitletsYou can check if Jupyter is installed successfully by running:
bash
jupyter notebook --versionStep-6: Running Jupyter Notebook in WSL
Now, let’s run Jupyter from within WSL and open it on Windows.
Move to your working directory inside the mounted drive (for example,
F:).Give yourself permission to read and write files:
bashcd /mnt/f sudo chmod -R u+rwX codesLaunch Jupyter Notebook:
bashjupyter notebook --ip=0.0.0.0 --port=8888 --no-browserOnce the notebook starts, you’ll see a URL in the terminal (starting with
http://127.0.0.1:8888). Copy that and open it in your web browser.To open your current folder directly in Windows Explorer, run:
bashexplorer.exe .
Summary
You now have a fully configured FEniCS environment inside Ubuntu (WSL) with:
- FEniCS installed via official repositories
- Python tools like
meshio,h5py, andlxml - Jupyter Notebook and Lab ready for running and testing simulations
Next, we’ll test the setup by running a simple simulation script to confirm everything works as expected.