# Error calling pylith within python - \_mpi dependency missing from pythia?

**URL:** <https://community.geodynamics.org/t/error-calling-pylith-within-python-mpi-dependency-missing-from-pythia/3522>\
**Category:** PyLith\
**Created:** [June 25, 2024, 9:10pm UTC](https://community.geodynamics.org/t/error-calling-pylith-within-python-mpi-dependency-missing-from-pythia/3522 "2024-06-25T21:10:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VolcanoloJack](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/volcanolojack/32/1987_2.png) [@VolcanoloJack](https://community.geodynamics.org/u/VolcanoloJack)\
**Post date:** [June 25, 2024, 9:10pm UTC](https://community.geodynamics.org/t/error-calling-pylith-within-python-mpi-dependency-missing-from-pythia/3522/1 "2024-06-25T21:10:49Z")

</div>

Hi everyone-

I am working on a project that calls pylith from within a larger python framework instead of the command line, but have run into some issues getting pylith to run under these circumstances. For context, I am running 4.0.0 installed from the .tar file on a WSL2 virtual machine running Ubuntu.

Within the installation, I have found the RunnerApp package and its demonstration in pylith\_runner.py, both of which should do what I’m trying to do. Their file paths are:

> Pylith-4.0.0/lib/python3/site-packages/pylith/apps/RunnerApp.py  
> Pylith-4.0.0/src/pylith-4.0.0/applications/pylith\_runner.py

Unfortunately, when I try to import the RunnerApp functions into a python script (after running setup.sh of course), I get the following error message:

> from pylith.apps.RunnerApp import RunnerApp  
> Traceback (most recent call last):  
> File “”, line 1, in   
> File “/home/jalbr/opt/Pylith-4.0.0/lib/python3.10/site-packages/pylith/apps/RunnerApp.py”, line 19, in   
> from pylith.apps.PyLithApp import PyLithApp  
> File “/home/jalbr/opt/Pylith-4.0.0/lib/python3.10/site-packages/pylith/apps/PyLithApp.py”, line 14, in   
> from .PetscApplication import PetscApplication  
> File “/home/jalbr/opt/Pylith-4.0.0/lib/python3.10/site-packages/pylith/apps/PetscApplication.py”, line 15, in   
> from pythia.mpi import Application  
> File “/home/jalbr/opt/Pylith-4.0.0/lib/python3.10/site-packages/pythia/mpi/ **init**.py”, line 14, in   
> from \_mpi import \*  
> ModuleNotFoundError: No module named ‘\_mpi’

This error seems to run through a chain of dependencies to the pythia module, which seems to be missing either another installed module or a local file “\_mpi”. **Would anyone know how to restore this dependency, or otherwise fix this issue? Alternatively, is there a better or more direct way of calling pylith from within python?**

Thank you so much!  
-Jack

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [June 25, 2024, 9:39pm UTC](https://community.geodynamics.org/t/error-calling-pylith-within-python-mpi-dependency-missing-from-pythia/3522/2 "2024-06-25T21:39:53Z")

</div>

PyLith applications do not run using the normal Python interpreter. They use a special version of the interpreter that is MPI aware, called `nemesis`. You will see that in all of the Python scripts included with PyLith (including the `pylith` script itself), the first line is `#!/usr/bin/env nemesis` rather than `#!/usr/bin/env python`.

If you want to run the PyLith application, then you need to invoke your Python script with `nemesis`. You ran run `nemesis FILENAME.py` or change the first line of your script to `#!/usr/bin/env nemesis` as we do in our Python scripts.
