Question
· Jun 26

How do I set up a virtual environment for Embedded Python in IRIS?

I am looking to create a Python virtual environment (venv) so that my imported/installed python packages can be separate on different namespaces in IRIS. I am able to go and create an environment, activate it, and install packages, but I am not sure how to ensure that Embedded Python methods actually point to this virtual environment. 

Is the best solution to just load the virtual environment at runtime, in each method? That seems like a bad solution. Has anyone run into this and found a good solution?

Product version: IRIS 2025.1
$ZV: IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2025.1 (Build 225_1U) Fri May 16 2025 12:22:16 EDT
Discussion (2)5
Log in or sign up to continue

Hi @Justin Millette. It isn't possible to support multiple in-process Python virtual environments simultaneously. This is because a Python virtual environment is defined at the operating system level, not the application level. A virtual environment consists of a specific Python executable and a set of associated libraries running within an OS-level process. Since IRIS itself is an OS-level process, it can only host a single Python interpreter when running Python code in-process. Supporting multiple virtual environments in this context would require multiple OS processes, which would negate the benefits of embedded execution. If you really need virtual environments, use normal client-side Python. 

Official, IRIS support only one version of python and one set of library (default in <installdir/mgr/python).

But you can find here a PoC of venv support in our interoperabilty framework https://grongierisc.github.io/interoperability-embedded-python/venv/.

The good new is that each componement of the interoperabilty has it's own process, it means it can run different version of python.

Remember it's a PoC and it's community based.

Give it a try, and let me know what you think of it.

img