Error Compiling C++ Code with Dijitso in FEniCS Environment FEniCS2019.1

Dear all,

For a new project on a compute cluster I am attempting to install legacy FEniCS using conda.

I use the following environment.yml file to create my conda environment:

name: newenv

  - conda-forge

  - fenics
  - pip
  - git
  - python >=3.8

Installation does not generate any errors.

Then, I try the following:

from dolfin import *

Exp = Expression('5', degree=0)

Upon which I receive the following error message:

dijitso failed to load existing file:
error is: cannot open shared object file: No such file or directory
dijitso failed to load existing file:
error is: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/home/user/.conda/envs/testenv/lib/python3.12/site-packages/dolfin/jit/", line 168, in compile_class
    submodule = dijitso.extract_factory_function(module, "create_" + module_name)()
  File "/home/user/.conda/envs/testenv/lib/python3.12/site-packages/dijitso/", line 47, in extract_factory_function
    function = getattr(lib, name)
AttributeError: 'NoneType' object has no attribute 'create_dolfin_expression_c14489d6e2980e09728dad365e75ccf0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.conda/envs/testenv/lib/python3.12/site-packages/dolfin/function/", line 400, in __init__
    self._cpp_object = jit.compile_expression(cpp_code, params)
  File "/home/user/.conda/envs/testenv/lib/python3.12/site-packages/dolfin/function/", line 158, in compile_expression
    expression = compile_class(cpp_data, mpi_comm=mpi_comm)
  File "/home/user/.conda/envs/testenv/lib/python3.12/site-packages/dolfin/jit/", line 170, in compile_class
    raise RuntimeError("Unable to compile C++ code with dijitso")
RuntimeError: Unable to compile C++ code with dijitso

My thoughts:
It appears that the issue may be related to a missing shared object file (libpetsc.so3.15) which is needed by dijitso during the compilation process. I think it is not necessary missing, but I think the environment variables are not correctly set up such that they point to the wrong location for this file.

What I tried:

  • “conda list” tells me that petsc version 3.20 is installed, and actually there is a file /home/user/.conda/envs/testenv/lib/

  • I tried installing fenics 2018.1 in the same way, and I get a similar error using the same example code. However, this time, it concerns a different .so-file, “”

  • Setting the LD_LIBRARY_PATH variable manually:

export LD_LIBRARY_PATH=/home/user/.conda/envs/testenv/lib:$LD_LIBRARY_PATH

Trying the above steps, the issue persists.
I did not manage to find a solution to the problem yet. I wanted to share the issue with you all in hopes of getting some suggestions to approach it.

Thank you in advance for your ideas.

Is it possible that you already had an existing installation, and recently upgraded it. If so, you may want to clear out the existing dijitso cache (typically located under $HOME/.cache), because there may be files there which were compiled for the old installation, which may well have been using instead of PETSc 3.20.

Thank you for your immediate response. I believe your answer may well be the solution, as I did indeed have an existing installation. However, this is an installation that is compiled from source, using the modules available on the cluster. When installing a new version via conda, I expected that the existing installation would not interfere with the conda environment in any way, but it seems I was wrong.

In $HOME/.cache I cannot find the existing dijitso cache. I suppose it could be found in another location, since I installed the existing version from source.

Thank you for your suggestion, this should help me resolve the problem. I will send an update once I got the new installation running.

Your output seems to suggest that it’s in


I’d give cleaning that up a try. Furthermore, if when building from source you had to export environment variables like LIBRARY_PATH or LD_LIBRARY_PATH in your .bashrc file (or similar), I’d undo those exports, just to make sure that they don’t interfere with the paths from conda.

dijitso also has its own housecleaning

dijitso clean

Fantastic, with your suggestions I was able to get a conda installation working. Following the instructions of @francesco-ballarin I undid the exports of LIBRARY_PATH and LD_LIBRARY_PATH. Subsequently I created a new conda environment and installed everything anew. Now, the above code snippet is working as expected.

Thank you all for your help.