Search code examples
pythonpython-3.xvirtualenvdevelopment-environmentpython-venv

Can we implement our python project in Python Virtual Environment for production environment?


Problem: We have two different python service which should be ran in a single server. Where we have a dependency clash. Say Project A needs module - older version while Project B needs the same module but with newer version.

To isolate we found Python Virtual Environment will solve this issue.

But the real question for me is the Virtual environment will be stable and accepted on the production level usage.

Or Is there any other way we can approach for the problem.


Solution

  • Yes, you can You can create virtual environment for first service where python version will be different and for second service, you can use different python version. you can set these environment in running path of your services (for example in supervisor which we use for running process)

    [program:service1] command=path_to_virtualenv_for_service1 python service1.py

    [program:service2] command=path_to_virtualenv_for_service2 python service2.py