Running python script via subprocess in streamlit gives ModuleNotFoundError


I’ve deployed my app to the Community Cloud. In the app (wouldn’t help to share the link since it’s login-guarded), I’m spinning off subprocesses running python scripts (e.g.,'python -m )) and I’m getting ModuleNotFoundErrors. It’s as though the python environment is not the same environment as the one that all of the dependencies have just been installed into. Please advise.

Hey @Eli_Lowry,

Thanks for sharing this question! Totally understand that you can’t share the app link, but can you please share a runnable code snippet that we can use to reproduce this issue?

@Caroline Thank you so much for your quick response. I apologize for it taking me this long to get back to you. I wanted to create a minimal example to demonstrate the issue I’m having. See here. I imagine this is an easy fix, but I can’t see into the environments on the machine in order to solve this myself.

I ended up figuring out where the python env I needed was: /home/adminuser/venv/bin/python. Thanks!

Use sys.executable to get the same python that is running your code.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.