# Fenics from Conda doesn't import

**URL:** https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502
**Category:** Uncategorized
**Created:** [June 11, 2020, 6:14pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502 "2020-06-11T18:14:50Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Ryan\_Vogt](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/ryan_vogt/32/552_2.png) [@Ryan\_Vogt](https://fenicsproject.discourse.group/u/Ryan_Vogt)
#### Post date: [June 11, 2020, 6:14pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/1 "2020-06-11T18:14:50Z")

</div>

Howdy,

So I’ve downloaded fenics several times in the past, with no issue. Today when I downloaded fenics using conda I get :

> > > > import dolfin  
> > > > Traceback (most recent call last):  
> > > > File “”, line 1, in   
> > > > File “/anaconda3/envs/optcontrol/lib/python3.7/site-packages/dolfin/ **init**.py”, line 142, in   
> > > > from .fem.assembling import (assemble, assemble\_system, assemble\_multimesh,  
> > > > File “/anaconda3/envs/optcontrol/lib/python3.7/site-packages/dolfin/fem/assembling.py”, line 34, in   
> > > > from dolfin.fem.form import Form  
> > > > File “/anaconda3/envs/optcontrol/lib/python3.7/site-packages/dolfin/fem/form.py”, line 12, in   
> > > > from dolfin.jit.jit import dolfin\_pc, ffc\_jit  
> > > > File “/anaconda3/envs/optcontrol/lib/python3.7/site-packages/dolfin/jit/jit.py”, line 18, in   
> > > > raise RuntimeError(“Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.”)  
> > > > RuntimeError: Could not find DOLFIN pkg-config file. Please make sure appropriate paths are set.

I have python 3.7.6 currently. Any suggestions how I can resolve this issue?

Thank you.

---

<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: [June 11, 2020, 6:18pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/2 "2020-06-11T18:18:39Z")

</div>

This might be of help: [RuntimeError: Could not find DOLFIN pkg-config file](https://fenicsproject.discourse.group/t/runtimeerror-could-not-find-dolfin-pkg-config-file/1735/2)

---

<div class="post-metadata">

### Author: ![Ryan\_Vogt](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/ryan_vogt/32/552_2.png) [@Ryan\_Vogt](https://fenicsproject.discourse.group/u/Ryan_Vogt)
#### Post date: [June 12, 2020, 3:49am UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/3 "2020-06-12T03:49:47Z")

</div>

I unfortunately don’t use J notebooks. I’ve always called my fenics programs via python command. I’m not sure what the issue is because I’ve downloaded fenics several times previous on different machines and I haven’t ran into this issue. Any other tips @dokken?

---

<div class="post-metadata">

### Author: ![azerad](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/azerad/32/1355_2.png) [@azerad](https://fenicsproject.discourse.group/u/azerad)
#### Post date: [June 12, 2020, 7:44am UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/4 "2020-06-12T07:44:21Z")

</div>

you can check if the environment is loaded by typing in the python terminal

#test if environment fenics is activated  
import os  
print(os.environ[‘PATH’])

and check if the environment fenics is present in the path:  
you should get something like

/anaconda3/envs/fenicsproject/bin:/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin

of course fenicsproject would be replaced by the name you gave to the environment where you did “conda install fenics”

did you “conda activate” the environment from the terminal or from the anaconda navigator GUI (which is apparently bugged) see the post [RuntimeError: Could not find DOLFIN pkg-config file](https://fenicsproject.discourse.group/t/runtimeerror-could-not-find-dolfin-pkg-config-file/1735)

---

<div class="post-metadata">

### Author: ![georgexxu](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@georgexxu](https://fenicsproject.discourse.group/u/georgexxu)
#### Post date: [February 16, 2021, 11:29pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/5 "2021-02-16T23:29:35Z")

</div>

Hi, Ryan, did you solve this problem? I happen to run into a similar issue.

---

<div class="post-metadata">

### Author: ![Ryan\_Vogt](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/ryan_vogt/32/552_2.png) [@Ryan\_Vogt](https://fenicsproject.discourse.group/u/Ryan_Vogt)
#### Post date: [February 16, 2021, 11:52pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/6 "2021-02-16T23:52:29Z")

</div>

Hi George,

I’ve found that if I make a python virtual environment with anaconda, and then install fenics (with the conda-forge command) via anaconda into that virtual environment then things work great. I just run my programs from this environment. I think the issue is that if you don’t have a closed virtual environment, there might be a chance that you pip installed something in the past that comes in conflict with anaconda.

---

<div class="post-metadata">

### Author: ![georgexxu](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@georgexxu](https://fenicsproject.discourse.group/u/georgexxu)
#### Post date: [February 17, 2021, 1:12am UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/7 "2021-02-17T01:12:23Z")

</div>

Hi, Ryan,  
I tried the following but it is still not working,

1. conda create -n fenicsproject
2. conda activate fenicsproject
3. conda install -c conda-forge python=3.8.1 fenics  
Is this what you did?  
Thank you!

---

<div class="post-metadata">

### Author: ![Ryan\_Vogt](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/ryan_vogt/32/552_2.png) [@Ryan\_Vogt](https://fenicsproject.discourse.group/u/Ryan_Vogt)
#### Post date: [February 17, 2021, 5:54am UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/8 "2021-02-17T05:54:23Z")

</div>

I would do

1. conda create -n fenicsproject python=3.7
2. conda activate fenicsproject
3. conda install -c conda-forge fenics

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 13, 2023, 9:23pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/9 "2023-06-13T21:23:49Z")

</div>

when I do the " 1. conda create -n fenicsproject python=3.7" , I get the error:  
PackagesNotFoundError: The following packages are not available from current channels:

- python=3.7

Can you help me with this?

---

<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: [June 14, 2023, 4:31am UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/10 "2023-06-14T04:31:55Z")

</div>

Conda no longer supports Python 3.7, ref: [Managing Python — conda 23.5.1.dev35 documentation](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-python.html)

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 14, 2023, 1:10pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/11 "2023-06-14T13:10:22Z")

</div>

So, what is your suggestion to install fenics on conda? consider creating a new environment. What should I do to install fenics on conda on mac if I want to use it on J notebook?  
Thank you so much for your help.

---

<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: [June 14, 2023, 2:02pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/12 "2023-06-14T14:02:55Z")

</div>

You should use a newer version of Python in your conda env

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 14, 2023, 2:17pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/13 "2023-06-14T14:17:36Z")

</div>

Can you help me which version I should install?  
You mean, if I install the newer version of python, I can install fenics with " conda install -c conda-forge fenics" ?

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 14, 2023, 2:30pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/14 "2023-06-14T14:30:25Z")

</div>

I updated the python to the 3.10 version but I still get error installing fenics.  
PackagesNotFoundError: The following packages are not available from current channels:

- fenics

---

<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: [June 14, 2023, 10:59pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/15 "2023-06-14T22:59:17Z")

</div>

What kind of system are you on?  
The fenics conda package is at [Fenics :: Anaconda.org](https://anaconda.org/conda-forge/fenics) and has a large variety of supported platforms and versions, see [Files :: Anaconda.org](https://anaconda.org/conda-forge/fenics/files?version=2019.1.0&channel=main)

---

<div class="post-metadata">

### Author: ![minrk](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/minrk/32/3866_2.png) [@minrk](https://fenicsproject.discourse.group/u/minrk)
#### Post date: [June 15, 2023, 8:00am UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/16 "2023-06-15T08:00:40Z")

</div>

It may be worth sharing the output of `conda info`. The fenics packages on conda don’t have builds for arm macs, for example.

If you do have an arm Mac, you can create an environment using intel packages (they will work, just not as fast) with:

```auto
conda create --override-channels -c conda-forge/osx-64 -c conda-forge/noarch -n fenics fenics

```

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 15, 2023, 4:42pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/17 "2023-06-15T16:42:24Z")

</div>

I have Pro M1 system which is arm. I used the command you suggested and activated the fenics environment and here is the conda info:  
active environment : fenics  
active env location : /opt/anaconda3/envs/fenics  
shell level : 2  
user config file : /Users/eli/.condarc  
populated config files : /Users/eli/.condarc  
conda version : 22.9.0  
conda-build version : 3.22.0  
python version : 3.9.13.final.0  
virtual packages : \_\_osx=12.5=0  
\_\_unix=0=0  
\_\_archspec=1=arm64  
base environment : /opt/anaconda3 (writable)  
conda av data dir : /opt/anaconda3/etc/conda  
conda av metadata url : None  
channel URLs : [conda-forge/osx-arm64](https://conda.anaconda.org/conda-forge/osx-arm64)  
[conda-forge/noarch](https://conda.anaconda.org/conda-forge/noarch)  
[main/osx-arm64](https://repo.anaconda.com/pkgs/main/osx-arm64)  
[main/noarch](https://repo.anaconda.com/pkgs/main/noarch)  
[r/osx-arm64](https://repo.anaconda.com/pkgs/r/osx-arm64)  
[r/noarch](https://repo.anaconda.com/pkgs/r/noarch)  
package cache : /opt/anaconda3/pkgs  
/Users/eli/.conda/pkgs  
envs directories : /opt/anaconda3/envs  
/Users/eli/.conda/envs  
platform : osx-arm64  
user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.13 Darwin/21.6.0 OSX/12.5  
UID:GID : 501:20  
netrc file : None  
offline mode : False

Now what should I do to install jupyter at this environment? I installed it with conda install jupyter but it does not open with this.  
Thank you so much for your help.

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 15, 2023, 5:04pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/18 "2023-06-15T17:04:15Z")

</div>

I tried all commands on [Files :: Anaconda.org](https://anaconda.org/conda-forge/fenics/files?version=2019.1.0&channel=main) and none of them worked. my system is M1 Pro.

---

<div class="post-metadata">

### Author: ![minrk](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/minrk/32/3866_2.png) [@minrk](https://fenicsproject.discourse.group/u/minrk)
#### Post date: [June 15, 2023, 10:07pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/19 "2023-06-15T22:07:15Z")

</div>

Same command, adding any number of packages:

```auto
conda create --override-channels -c conda-forge/osx-64 -c conda-forge/noarch -n fenics fenics jupyterlab matplotlib …

```

Or to add packages to an existing env, change `create` to `install`.

To use this env, you’ll want to run

`conda activate fenics` after which you can run `JupyterLab` etc.

---

<div class="post-metadata">

### Author: ![EliMhz](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/elimhz/32/5445_2.png) [@EliMhz](https://fenicsproject.discourse.group/u/EliMhz)
#### Post date: [June 16, 2023, 1:25pm UTC](https://fenicsproject.discourse.group/t/fenics-from-conda-doesnt-import/3502/20 "2023-06-16T13:25:54Z")

</div>

Thank you so much! It worked!
