The solution is to detect the Python executable directy with sys.executable:
```python
streamlit_app.py
import streamlit as st
import subprocess
import sys
subprocess.run([f"{sys.executable}", "script.py"])
```
This ensures that script.py is running under the same Python executable as your Streamlit code—where your Python dependencies are installed.
Relevant links
https://stackoverflow.com/questions/69947867/run-portion-of-python-code-in-parallel-from-a-streamlit-app/69948545#69948545
https://discuss.streamlit.io/t/modulenotfounderror-no-module-named-cv2-streamlit/18319/3?u=snehankekre
https://docs.python.org/3/library/sys.html#sys.executable
