Using the fenics project with spyder

I have installed the fenics project using anaconda.

I followed the following commands and I believe that the installation was successful:

conda create -n fenicsproject -c conda-forge fenics

source activate fenicsproject

Now, I want to use fenics with my IDE spyder. Anaconda-navigator is complaining that I cannot install spyder in the fenicsproject environment.

Is there any way to resolve this issue?

Update: I ran conda install spyder in the fenicsproject environment and got this very long message from the terminal. I am not really sure how to go about fixing it.
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  • matplotlib-base β†’ python[version=’>=2.7,<2.8.0a0|>=3.5,<3.6.0a0’]
  • olefile β†’ python[version=’>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0’]
  • pyparsing β†’ python[version=’>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0’]
  • python-dateutil β†’ python[version=’>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0’]
  • wheel β†’ python[version=’>=3.9,<3.10.0a0’]

Your python: python=3.8

If python is on the left-most side of the chain, that’s the version you’ve asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with each other:

Output in format: Requested package β†’ Available versions

Package libgfortran5 conflicts for:
petsc β†’ libgfortran=5 β†’ libgfortran5
slepc4py β†’ mpich[version=’>=3.3.2,<4.0.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
hdf5 β†’ libgfortran=5 β†’ libgfortran5
superlu_dist β†’ libgfortran=5 β†’ libgfortran5
superlu β†’ libgfortran5[version=’>=9.3.0’]
hdf5 β†’ libgfortran5[version=’>=9.3.0’]
slepc β†’ libgfortran5[version=’>=9.3.0’]
mpi4py β†’ mpich[version=’>=3.4,<4.0.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
libopenblas β†’ libgfortran=5 β†’ libgfortran5
suitesparse β†’ libopenblas[version=’>=0.3.3,<1.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
ptscotch β†’ mpich[version=’>=3.3.2,<4.0.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
parmetis β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
mumps-mpi β†’ libgfortran5[version=’>=9.3.0’]
mpich β†’ libgfortran=5 β†’ libgfortran5
mumps-mpi β†’ libgfortran=5 β†’ libgfortran5
superlu_dist β†’ libgfortran5[version=’>=9.3.0’]
petsc β†’ libgfortran5[version=’>=9.3.0’]
superlu β†’ libgfortran=5 β†’ libgfortran5
petsc4py β†’ libgfortran5[version=’>=9.3.0’]
mpich β†’ libgfortran5[version=’>=9.3.0’]
libgfortran β†’ libgfortran5
hypre β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
slepc β†’ libgfortran=5 β†’ libgfortran5
scalapack β†’ libgfortran5[version=’>=9.3.0’]
fenics-dolfin β†’ hdf5[version=’>=1.10.6,<1.10.7.0a0’,build=mpi_mpich_*] β†’ libgfortran5[version=’>=9.3.0’]
libopenblas β†’ libgfortran5[version=’>=9.3.0’]
libblas β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
scalapack β†’ libgfortran=5 β†’ libgfortran5
numpy β†’ libopenblas[version=’>=0.3.3,<1.0a0’] β†’ libgfortran5[version=’>=9.3.0’]
petsc4py β†’ libgfortran=5 β†’ libgfortran5

Package libcxx conflicts for:
numpy β†’ python[version=’>=3.9,<3.10.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
olefile β†’ python[version=’>=3.5,<3.6.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
petsc β†’ hdf5[version=’>=1.10.6,<1.10.7.0a0’,build=mpi_mpich_*] β†’ libcxx[version=’>=11.0.0|>=9.0.1|>=4.0.1|>=11.0.1|>=9.0.0’]
sympy β†’ python[version=’>=3.6,<3.7.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
lcms2 β†’ libtiff[version=’>=4.1.0,<5.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1’]
readline β†’ ncurses[version=’>=6.2,<7.0a0’] β†’ libcxx[version=’>=4.0.1’]
python=3.8 β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
boost-cpp β†’ libboost==1.73.0=hd4c2dcd_11 β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
kiwisolver β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=11.0.1’]
lz4-c β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.0’]
matplotlib-base β†’ libcxx[version=’>=10.0.0|>=4.0.1’]
slepc β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1|>=9.0.0’]
matplotlib β†’ libcxx[version=’>=4.0.1’]
libnghttp2 β†’ libcxx[version=’>=10.0.0|>=11.0.1’]
gmp β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=10.0.1’]
hypre β†’ libcxx[version=’>=9.0.1’]
kiwisolver β†’ libcxx[version=’>=10.0.0|>=4.0.1’]
spyder β†’ pyqt[version=’>=5.6,<5.13’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
pip β†’ python[version=’>=3.6,<3.7.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
expat β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
matplotlib β†’ matplotlib-base[version=’>=3.3.4,<3.3.5.0a0’] β†’ libcxx[version=’>=10.0.0|>=11.0.1’]
fenics-ffc β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
fenics-ufl β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
hdf5 β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.0’]
hdf5 β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libcxx[version=’>=11.0.1’]
libtiff β†’ libcxx[version=’>=10.0.0|>=4.0.1’]
cmake β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
sqlite β†’ ncurses[version=’>=6.2,<7.0a0’] β†’ libcxx[version=’>=4.0.1’]
fenics-dolfin β†’ mpich[version=’>=3.3.2,<4.0.0a0’] β†’ libcxx[version=’>=10.0.0|>=10.0.1|>=11.0.1|>=4.0.1’]
slepc β†’ libcxx[version=’>=10.0.1’]
wheel β†’ python β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
zstd β†’ lz4-c[version=’>=1.9.2,<1.10.0a0’] β†’ libcxx[version=’>=11.0.0’]
cycler β†’ python[version=’>=3.9,<3.10.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
pkgconfig β†’ python[version=’>=3.7,<3.8.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
matplotlib-base β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=11.0.1’]
libcurl β†’ krb5[version=’>=1.17.1,<1.18.0a0’] β†’ libcxx[version=’>=11.0.0|>=4.0.1|>=11.0.1’]
ptscotch β†’ mpich[version=’>=3.3.2,<4.0.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1’]
metis β†’ libcxx[version=’>=4.0.1’]
python=3.8 β†’ libffi[version=’>=3.3,<3.4.0a0’] β†’ libcxx[version=’>=11.0.0’]
libtiff β†’ zstd[version=’>=1.4’] β†’ libcxx[version=’>=11.0.1’]
icu β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.0’]
boost-cpp β†’ libcxx[version=’>=11.0.0’]
fenics-dolfin β†’ libcxx[version=’>=11.0.0’]
hypre β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1’]
suitesparse β†’ libcxx[version=’>=4.0.1|>=9.0.0’]
mpc β†’ gmp[version=’>=6.1.2’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=10.0.1’]
certifi β†’ python[version=’>=3.7,<3.8.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
slepc4py β†’ mpich[version=’>=3.3.2,<4.0.0a0’] β†’ libcxx[version=’>=10.0.0|>=10.0.1|>=11.0.1|>=4.0.1’]
zstd β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
libedit β†’ ncurses[version=’>=6.2,<7.0a0’] β†’ libcxx[version=’>=4.0.1’]
pybind11 β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=10.0.1’]
six β†’ python[version=’>=3.9,<3.10.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
mpmath β†’ python[version=’>=3.9,<3.10.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
mpich β†’ libcxx[version=’>=11.0.1|>=4.0.1’]
pybind11 β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=11.0.1’]
fenics-dijitso β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
fenics β†’ fenics-dolfin==2019.1.0=py38hd7c8441_18 β†’ libcxx[version=’>=10.0.0|>=11.0.0|>=4.0.1|>=11.0.1’]
suitesparse β†’ tbb[version=’>=2019.1’] β†’ libcxx[version=’>=10.0.0|>=11.0.1’]
mpi4py β†’ mpich[version=’>=3.3,<3.4.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
libffi β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.0’]
ncurses β†’ libcxx[version=’>=4.0.1’]
krb5 β†’ libcxx[version=’>=11.0.0|>=4.0.1’]
pyparsing β†’ python β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
superlu_dist β†’ metis[version=’>=5.1.0,<5.2.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1|>=9.0.1’]
python_abi β†’ python=3.8 β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
tbb β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
eigen β†’ libcxx[version=’>=11.0.0|>=4.0.1’]
parmetis β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1’]
setuptools β†’ python[version=’>=3.6,<3.7.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
tornado β†’ python[version=’>=3.9,<3.10.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
python-dateutil β†’ python β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
pillow β†’ libtiff[version=’>=4.1.0,<5.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
mumps-mpi β†’ metis[version=’>=5.1.0,<5.2.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1|>=9.0.1’]
petsc β†’ libcxx[version=’>=10.0.1’]
petsc4py β†’ mpich[version=’>=3.3.2,<4.0.0a0’] β†’ libcxx[version=’>=10.0.0|>=10.0.1|>=11.0.1|>=4.0.1’]
mpfr β†’ gmp[version=’>=6.1.2’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=10.0.1’]
fenics-fiat β†’ python[version=’>=3.8,<3.9.0a0’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=11.0.1’]
parmetis β†’ libcxx[version=’>=9.0.1’]
superlu_dist β†’ libcxx[version=’>=10.0.1’]
scalapack β†’ mpich[version=’>=3.3,<4.0.0a0’] β†’ libcxx[version=’>=11.0.1|>=4.0.1’]
gmpy2 β†’ gmp[version=’>=6.1.2’] β†’ libcxx[version=’>=10.0.0|>=4.0.1|>=10.0.1|>=11.0.1’]

Package libopenblas conflicts for:
hypre β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
scalapack β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
superlu β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
petsc4py β†’ numpy[version=’>=1.16.5,<2.0a0’] β†’ libopenblas[version=’>=0.3.3,<1.0a0’]
superlu_dist β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
fenics-dijitso β†’ numpy β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
fenics-dolfin β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0|>=0.3.3,<1.0a0’]
suitesparse β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
matplotlib β†’ numpy[version=’>=1.14.6,<2.0a0’] β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
mumps-mpi β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
slepc β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
fenics-fiat β†’ numpy β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
numpy β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
suitesparse β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.3,<1.0a0’]
fenics-ffc β†’ numpy β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
numpy β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
petsc β†’ libblas[version=’>=3.8.0,<4.0a0’] β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
liblapack β†’ libblas==3.9.0=8_openblas β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
fenics-ufl β†’ numpy β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
libcblas β†’ libblas==3.9.0=8_openblas β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
matplotlib-base β†’ numpy[version=’>=1.16.6,<2.0a0’] β†’ libopenblas[version=’>=0.2.20,<0.2.21.0a0|>=0.3.2,<0.3.3.0a0|>=0.3.3,<1.0a0’]
libblas β†’ libopenblas[version=’>=0.3.12,<0.3.13.0a0|>=0.3.12,<1.0a0’]
slepc4py β†’ numpy[version=’>=1.16.5,<2.0a0’] β†’ libopenblas[version=’>=0.3.3,<1.0a0’]

Package mpich conflicts for:
superlu_dist β†’ parmetis[version=’>=4.0.3,<4.1.0a0’] β†’ mpich[version=’>=3.3,<4.0.0a0’]
petsc β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
mpi4py β†’ mpich[version=’>=3.3,<3.4.0a0|>=3.4,<4.0.0a0’]
petsc β†’ hdf5[version=’>=1.10.6,<1.10.7.0a0’,build=mpi_mpich_] β†’ mpich[version=’>=3.3,<4.0.0a0’]
mumps-mpi β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
scalapack β†’ mpich[version=’>=3.3,<4.0.0a0’]
slepc β†’ mpich[version=’>=3.3,<4.0.0a0’]
parmetis β†’ mpich[version=’>=3.3,<4.0.0a0’]
fenics-dolfin β†’ hdf5[version=’>=1.10.6,<1.10.7.0a0’,build=mpi_mpich_
] β†’ mpich[version=’>=3.3,<3.4.0a0|>=3.3,<4.0.0a0|>=3.4,<4.0.0a0’]
hypre β†’ mpich[version=’>=3.3,<4.0.0a0’]
superlu_dist β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
slepc4py β†’ slepc[version=’>=3.13.4,<3.14.0a0’] β†’ mpich[version=’>=3.3,<4.0.0a0’]
fenics-dolfin β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
slepc4py β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
mumps-mpi β†’ parmetis[version=’>=4.0.3,<4.1.0a0’] β†’ mpich[version=’>=3.3,<4.0.0a0’]
fenics β†’ fenics-dolfin==2019.1.0=py38hd7c8441_18 β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
hdf5 β†’ mpich[version=’>=3.3,<4.0.0a0’]
ptscotch β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
slepc β†’ petsc[version=’>=3.13.6,<3.14.0a0’] β†’ mpich[version=’>=3.3.2,<4.0.0a0’]
petsc4py β†’ mpich[version=’>=3.3.2,<4.0.0a0’]

Package liblapack conflicts for:
fenics-dolfin β†’ numpy[version=’>=1.16.6’] β†’ liblapack[version=’>=3.8.0,<4.0a0’]
mumps-mpi β†’ scalapack[version=’>=2.0.2,<2.1.0a0’] β†’ liblapack[version=’>=3.8.0,<4.0.0a0’]

…
It’s a very long error message and wouldn’t fit here…

I do not know if I understood you correctly. You created the environment with FEniCS via

conda create -n fenicsproject -c conda-forge fenics

Then you opened anaconda and started spyder? I do not know which environment anaconda spyder is using, but I think it isn’t your fenicsproject. I also had troubles to get anaconda spyder running with fenics, thats why I switched to miniconda. Try this in your terminal:

conda -create fenicsproject -c conda-forge fenics=2019 spyder
conda activate fenicsproject
spyder

Then spyder should open (without the anaconda-dialogue) and you can import fenics

from fenics import *

This works for me. If you want to use jupyter notebook then you need nb_conda_kernels

conda install -c conda-forge nb_conda_kernels jupyter

1 Like

Hi Yannik,

Thanks for getting back.

I installed fenics using conda create -n fenicsproject -c conda-forge fenics. That’s what the instructions in the Fenics website says.

Then, I entered into the fenicsproject environment using the command conda install spyder. I got the error message above. I can’t install spyder in this environment.

I tried typing conda -create fenicsproject -c conda-forge fenics=2019 spyder as you said above in the terminal.

I got the error:

CommandNotFoundError: No command β€˜conda fenicsproject’.
Did you mean β€˜conda inspect’?

Is there a typo in the command?

Yes, sorry. My bad. It should be

onda create --name fenicsproject -c conda-forge fenics=2019 spyder

followed by

conda activate fenicsproject

then

spyder

1 Like

I am using fenics from terminal too, it wpuld be great to run it in vscode. So tried what Yannik wrotes get the following error:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - vscode

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Does anyone know how to get around this? Here people says it’s solved when updated, here others says it should be downgraded. I am super confused.

First of all, why are you citing me wrong? I’ve never written

conda create --name fenicsproject -c conda-forge fenics=2019 vscode

However from reading your error messages it seems that there is no package vscode available to install via conda. You can’t simply type

conda create --name fenicsproject -c conda-forge fenics=2019 xxx

with xxx your IDE of choice. They have to be installable via conda. Also your two links won’t help you. What you should do:

  1. Install VS code
  2. Create an conda environment with fenics, e.g. via
    conda create --name fenicsproject -c conda-forge fenics=2019
  3. Activate this conda environment (fenicsproject) in VS code

I’m not using VS code so I can’t tell you how this works. But perhaps you can find a solution here.

2 Likes

It wasn’t my intention, I just wanted to wrote how I wrote it by copying what you wrote. Thank you so much for the answer.

Thank you very much for this solution. I finally got it to work!

Howdy!
I have Anaconda Navigator, and was trying to use the known Poisson demo with the preloaded Spyder IDE, but it wasn’t catching the newly installed FEniCS within the program. Essentially, it was a warning on the lines where FEniCS syntax is used (yellow triangle said β€˜undefined names’).

I tried what @Yannik said since it seemed to jive with the idea that I needed Spyder to activate the FEniCS environment… First I closed out Spyder and Anaconda Navigator and opened a fresh Terminal.
in Terminal, I typed:

conda create --name fenicsproject -c conda-forge fenics=2019 spyder
conda activate fenicsproject
spyder

I have a conda environment existing at home/user/anaconda3/envs/fenicsproject
The Terminal showed a change from (base) user@system:~ to (fenicsproject) user@system:~
However, when I typed the last line, it said that

Command 'spyder' not found but can be installed with: 
sudo apt install spyder

So I reinstalled Spyder, and it warned me that it was Spyder 3.0 (now on 5.0), and the code still is giving me the warning.

I just need the program to load the FEniCS module, so I am unsure what is going wrong. Any ideas as to how I can activate the environment so that now and the next time I open Spyder it will recognize FEniCS syntax on this system?

Hi EngineerMama,

Does your code run? In my (working) conda-spyder setup, when I use

from fenics import *

I get the same yellow triangle warnings, but the code runs correctly.

What you’re seeing is part of the reason why wildcard imports are not recommended when programming in Python: you don’t know exactly what names you’re importing. (See the last bullet point on β€œwildcard imports”.) In this case, you’re getting warnings because your error-checker (it appears to be pyflakes) doesn’t know what names you’re importing either. Note that if you use the same syntax on a very standard python module (e.g. from os import *, you get the same warning (I do, anyway). Most FEniCS codes use the wildcard import because the resulting code reads more like the math that it represents.

You can verify that your setup is working by doing:

from fenics import *
dir()

This will tell you all the names that are defined in the global namespace. If the warnings bother you, you can instead use

import fenics as fe

but note that any fenics-defined names will now have to be addressed as fe.<name>, e.g.

u0 = fe.Constant(0.0)

Regards,
Connor

2 Likes

@conpierce8 THANK YOU!

I forgot about the Pythonic way of doing things as I was so caught up in how hard it’s been to get FEniCS installed. I still think it’s quirky how the Anaconda app doesn’t recognize that Spyder is installed in the environment, but since the environment will launch Spyder from the Terminal, I can adapt.
My fear was that it had somehow not installed, but with the updated syntax the demo code now doesn’t have the yellow triangles! (as you can see, where I’ve added the fe. before the name, the triangles from my previous screenshot are now gone)
image

1 Like