'Behavior of Python subprocess on django+nginx

I have a simple code like:

subprocess.run(
    ["python3",
     "action.py",
     "--options"]
)

In action.py I import some packages, perform a small script

It works properly when I launch it on the built-in Django-server, but when I add Nginx-server as a wrapper, I get

 "ModuleNotFoundError: No module named 'modulename'".

Why this error might occur exactly with Nginx and how I can correct it?

Launch with shell=True or venv="path/to/venv" don`t work for me



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source