DagsterImportError: Encountered ImportError: `<x>: cannot open shared object file: No such file or directory` while importing module main
Last updated: October 9, 2025
Problem
You encounter an error of DagsterImportError: Encountered ImportError: <x>: cannot open shared object file: No such file or directory while importing module main
Example full error
dagster._core.errors.DagsterImportError: Encountered ImportError: `libexpat.so.1: cannot open shared object file: No such file or directory` while importing module main. Local modules were resolved using the working directory `/venvs/d14d9acec24c/lib/python3.12/site-packages/working_directory/root`. If another working directory should be used, please explicitly specify the appropriate path using the `-d` or `--working-directory` for CLI based targets or the `working_directory` configuration option for workspace targets.Possible causes
This error typically happens when the Docker image used for Dagster+ Serverless does not have the indicated runtime dependency installed.
Solutions
You can use your own custom Docker image with the missing dependency included in it, or
You can disable PEX-based deploys and use lifecycle hooks to install the missing dependency in the
dagster_cloud_pre_install.shscript. Note that this can cause it to take longer to deploy your code than with a PEX-based deploy.