Fenics installation error

1,341 views
Skip to first unread message

Maryam Hakimzadeh

unread,
Sep 21, 2020, 11:35:41 AM9/21/20
to fenics-support
Dear fenics-support members,

I am trying to install fenics. I have installed virtual Ubuntu on my Windows 10, and the version of Ubuntu is Ubuntu 20.04.1 LTS.
I also have installed Anaconda on my ubuntu, with version: 5.3.0. The version of Python on my ubuntu is 3.7.1. 
Following the installation procedure, I entered the following command from the Fenics website: 
"
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install --no-install-recommends fenics
"
And I get this message: fenics is already the newest version (1:2019.2.0.2~ppa1~focal1).
0 upgraded, 0 newly installed, 0 to remove and 67 not upgraded.

However, when I enter this command to import fenics: python -c 'import fenics', I get this error: ModuleNotFoundError: No module named 'fenics'

So, it seems that fenics has been installed, but Ubuntu is not recognizing the fenics model! 
Any help is much appreciated!

Jesus Vellojin

unread,
Sep 21, 2020, 11:45:08 AM9/21/20
to fenics-support
Dear maryamhaki,

The latest version of Fenics is imported using the Dolfin module. Use python -c 'import dolfin' .

Cheers

Maryam Hakimzadeh

unread,
Sep 21, 2020, 11:48:51 AM9/21/20
to fenics-support
Thanks Jesus!
I tried it, but it also does not recognize the dolfin module! Here is the error: ModuleNotFoundError: No module named 'dolfin'

Jesus Vellojin

unread,
Sep 21, 2020, 12:14:34 PM9/21/20
to fenics-support
Dear Maryam,

Maybe it is because Ubuntu is using Python 2 as default. Try python3 -c 'import dolfin' instead.

Cheers.

Maryam Hakimzadeh

unread,
Sep 21, 2020, 12:16:18 PM9/21/20
to fenics-support
Thanks. Unfortunately, it gives the same error: ModuleNotFoundError: No module named 'dolfin'

Jesus Vellojin

unread,
Sep 21, 2020, 12:33:10 PM9/21/20
to fenics-support
Maybe you are inside some conda virtual environment?.  If "(base)" appear in front of your terminal prompt, then you are inside of a conda environment.  To exit the environment run conda deactivate and then run 
python3 -c 'import dolfin' again, making sure that (base) is not present in your prompt.

To disable the auto activate feature of anaconda, run
conda config
--set auto_activate_base False
source
~/.bashrc

To reactivate, set it to True:
conda config --set auto_activate_base True
source ~/.bashrc

Maryam Hakimzadeh

unread,
Sep 21, 2020, 12:39:40 PM9/21/20
to fenics-support
Dear Jesus, 
Thank you so much! It worked!
Really appreciate your support!

Maryam Hakimzadeh

unread,
Nov 11, 2020, 9:24:29 PM11/11/20
to fenics-support
Dear Fenics-support member,


I have another question regarding the Fenics run. When I use anaconda on windows to edit my .py files and then run fenics with virtual ubuntu (using command prompt), it works almost properly (It creates .pvd or other files included in the python code). However, by running Fenics on the virtual ubuntu command prompt, the "matplotlib" figures or "type()" do not pop up on the command window. 
So, I decided to use the Jupyter notebook installed on the virtual ubuntu. However, to run that, based on your previous advice, I need to deactivate anaconda. If not, I'll again encounter the error: "No module named 'Dolfin"! And by deactivating anaconda, Jupyter will not work. Now, I don't know how I should use Jupyter notebook on virtual ubuntu to run the Fenics.

Any help is greatly appreciated,


Jesus Vellojin

unread,
Nov 11, 2020, 9:57:40 PM11/11/20
to fenics-support
Dear Maryam,

Assuming that you're going to use the Ubuntu Fenics installation, you can install jupyter notebook by running sudo apt install jupyter or python3 -m pip install jupyter-notebook. I recommend the first option since it will install directly from the Ubuntu repos. Then you will be able to use jupyter notebook outside Anaconda.

Cheers.

Maryam Hakimzadeh

unread,
Nov 11, 2020, 10:22:49 PM11/11/20
to fenics-support
Thanks Jesus for your response. 
Would you please tell me how should I open jupyter notebook on Ubuntu now? Because I tried "jupyter notebook " command after "conda deactivate", and it says: "Start : This command cannot be run due to the error: The system cannot find the file specified."
I believe that this is because of conda deactivate, because it works without this command.

Thank you very much!

Jesus Vellojin

unread,
Nov 11, 2020, 10:37:10 PM11/11/20
to fenics-support
That error is because jupyter notebook is trying to launch a browser, which do not exist in WSL. To fix this you can follow the tutorial given by https://harshityadav95.medium.com/jupyter-notebook-in-windows-subsystem-for-linux-wsl-8b46fdf0a536

The most important parts is that you need to add an alias to run the notebooks with no browser. To do this, first run nano ~/.bashrc . At the end of the file, add the line alias jupyter-notebook="~/.local/bin/jupyter-notebook --no-browser". This will avoid jupyter from trying to open a browser. Then, try to run now jupyter-notebook. The first time running this will give you an url address, paste it on your Windows browser and follow the steps.

Maryam Hakimzadeh

unread,
Nov 13, 2020, 12:22:32 PM11/13/20
to Jesus Vellojin, fenics-support
Thank you very much Jesus for your help!


--
You received this message because you are subscribed to the Google Groups "fenics-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fenics-suppor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fenics-support/0e8c370e-a277-451f-b82e-07852c02d1bbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages