Skip to content

ImportError when using dolfinx in PythonCall #729

Description

@touste

Affects: PythonCall

Describe the bug

using CondaPkg
]conda add fenics-dolfinx

using PythonCall
dolfinx = pyimport("dolfinx")

ERROR: LoadError: Python: ImportError: libdolfinx.so.0.10: cannot open shared object file: No such file or directory

What's strange is

using CondaPkg
]conda run python
>>> import dolfinx

works fine

Your system
Ubuntu 24.04, Julia 1.12.1, PythonCall 0.9.30. Python and Conda managed by CondaPkg (default environment).

Activity

  1. touste commented on Dec 2, 2025

    @touste
    Author

    The issue somehow disappeared when I started from a clean environment, I'm not able to reproduce it anymore...

  2. aibiliGaferreira commented on Feb 24, 2026

    @aibiliGaferreira

    I'm having a similar issue, but only when using Ubuntu WSL. It works fine on Windows, but when I try running the same script on WSL I get the error:

    julia> pyimport("fundus_image_toolbox")
    ERROR: Python: OSError: libmkl_gnu_thread.so.2: cannot open shared object file: No such file or directory
    Python stacktrace:
     [1] __init__
       @ ctypes /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/ctypes/__init__.py:379
     [2] _load_global_deps
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/torch/__init__.py:366
     [3] _preload_cuda_deps
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/torch/__init__.py:344
     [4] _load_global_deps
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/torch/__init__.py:388
     [5] <module>
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/torch/__init__.py:430
     [6] <module>
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/fundus_image_toolbox/circle_crop/eyeq_preprocess.py:2
     [7] <module>
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/fundus_image_toolbox/circle_crop/__init__.py:1
     [8] <module>
       @ /mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/fundus_image_toolbox/__init__.py:1
    Stacktrace:
     [1] pythrow()
       @ PythonCall.Core ~/.julia/packages/PythonCall/83z4q/src/Core/err.jl:77
     [2] errcheck
       @ ~/.julia/packages/PythonCall/83z4q/src/Core/err.jl:10 [inlined]
     [3] pyimport(m::String)
       @ PythonCall.Core ~/.julia/packages/PythonCall/83z4q/src/Core/builtins.jl:1458
     [4] top-level scope
       @ REPL[7]:1
    

    This is what my CondaPkg.toml looks like:

    [deps]
    pytorch = ""
    numpy = ""
    stringzilla = ""
    
    [pip.deps]
    fundus_image_toolbox = ""
    
    

    I've tried adding the mkl packages to CondaPkg.toml, as well as fixing a python version (3.12), but none of those attempts solved the issue. However, if I run

    julia> using CondaPkg
    pkg> conda run python
    >>> import fundus_image_toolbox as fit
    Module missing, downloading it from https://github.com/berenslab/MIDL24-segmentation_quality_control...
    Adjusting imports...
    Done.
    Module missing, downloading it from https://github.com/dsc/bunch...
    >>> fit.__file__
    '/mnt/d/projects/FOCAL/.CondaPkg/.pixi/envs/default/lib/python3.12/site-packages/fundus_image_toolbox/__init__.py'
    >>> 
    

    it works. I've also looked at .CondaPkg, at the file libmkl_gnu_thread.so.2 is there, so I'm not sure what the issue could be (.CondaPkg/.pixi/envs/default/lib/libmkl_intel_thread.so.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions