Import dolfin shows "Could not find DOLFIN pkg-config file"

I install dolfin in ubuntu 20 with the command:

 conda install -c conda-forge -c conda-forge/label/fenics-dev fenics-dolfin

Then typed the the command in the terminal:

python -c "import dolfin;print(dolfin.__file__)"

The following errors occur:

(test7) chenxiaoxuan@Turing:~$ python -c "import dolfin;print(dolfin.__file__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chenxiaoxuan/anaconda3/envs/test7/lib/python3.7/site-packages/dolfin/__init__.py", line 142, in <module>
    from .fem.assembling import (assemble, assemble_system, assemble_multimesh,
  File "/home/chenxiaoxuan/anaconda3/envs/test7/lib/python3.7/site-packages/dolfin/fem/assembling.py", line 34, in <module>
    from dolfin.fem.form import Form
  File "/home/chenxiaoxuan/anaconda3/envs/test7/lib/python3.7/site-packages/dolfin/fem/form.py", line 12, in <module>
    from dolfin.jit.jit import dolfin_pc, ffc_jit
  File "/home/chenxiaoxuan/anaconda3/envs/test7/lib/python3.7/site-packages/dolfin/jit/jit.py", line 18, in <module>
    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.

Typing conda list fen gives

#
# Name                    Version                   Build  Channel
fenics-dijitso            2019.1.0                   py_9    conda-forge/label/cf202003
fenics-dolfin             2019.1.0         py37h1c4d066_1    conda-forge/label/cf202003
fenics-ffc                2019.1.0                   py_9    conda-forge/label/cf202003
fenics-fiat               2019.1.0                   py_9    conda-forge/label/cf202003
fenics-libdolfin          2019.1.0             h370d018_1    conda-forge/label/cf202003
fenics-ufl                2019.1.0                   py_9    conda-forge/label/cf202003

The pkg-conf is also installed:

# Name                    Version                   Build  Channel
pkg-config                0.29.2               h1bed415_8    defaults

How can I fix this? Thanks in advance.

The first thing to note is that these builds are extremely out of date. The latest build is number 49. Build 9 is almost 5 years out of date. Possibly because you are using Python 3.7, which hasn’t been supported in years. Start by trying tup create a fresh environment, e.g.

conda create -c conda-forge -n test-fenics fenics-dolfin python=3.10 mpich

And when reporting an issue with conda, it’s always a good idea to include the output of conda env export.