Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

How to install fenics in Ubuntu using PIP for a particular python environment?

I want to install fenics in Ubuntu 20. First I made a python environment using:

sudo apt install python3-venv

Then inside the folder I want to make an environment I open a terminal and use:

python3 -m venv myproject

myproject is the name of the environment I made.

I then activate my environment:

source myproject/bin/activate

To install fenics for this particular environment while I activated the environment, I use:

pip install fenics

I verify the installation using pip list which returns:

Package        Version       
-------------- --------------
fenics         2019.1.0      
fenics-dijitso 2019.1.0      
fenics-ffc     2019.1.0.post0
fenics-fiat    2019.1.0      
fenics-ufl     2019.1.0      
mpmath         1.1.0         
numpy          1.19.4        
pip            20.0.2        
pkg-resources  0.0.0         
setuptools     44.0.0        
sympy          1.7.1 

I try to import fenics using:

python -c "import fenics"

But I get the error below stating there is not fenics module:

raceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fenics'

What is the problem? Hopefully, after successful installation of fenics, I can install Spyder and other python packages and will be able to use fenics inside spyder.

Edit I want to install fenics in a python virtual environment.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The issue here is that fenics is just a meta-package and it does not contain any library that you can use in your Python code.

Quoting from the README for the fenics project :

This package contains a single file, setup.py, that allows all of the FEniCS Python components to be installed from PyPI using pip:

pip3 install fenics

Actual use of the library is done via

import ffc

All different components are under this package. For example, fenics-fiat is available as ffc.fiatinterface.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...