I've installed IronPython 3.4 (https://github.com/IronLanguages/ironpython3/releases/tag/v3.4.1) and I'm trying to run several font-related python scripts that depend upon an active VENV (FontTools, ftCLI, and some other packages).
Is this even possible? I have been doing some research on IronPython, but nothing mentions virtual environments.
Is it possible to accomplish what I need? Is there another solution that will run a script in an active VENV using C#?
Thank you for any guidance.
In summary, you need to pass the full path to the
venvversion of Python.A
venvconsists of:/home/bob/dev/project/.venvorC:/Users/Bob/dev/project/.venvwhich contains the the things which constitute thevenv.binfor Linux)activatewhich modifies the environment of the current shell so that those scripts are called first, and so that Python will look insite-packagesfirst.If called from a shell, such as Bash, Zsh, Powershell or Cmd, the
activatescript will modify the environment of the shell, so that when you typepython, the version of python is thevenvpython. You "activate" the venv with eithercall .venv/Scripts/activate.cmdfor windows, orsource .venv/bin/activatefor Linux.However if you just want to ensure that the python module or file is run in the
venv, all you have to do is specify the full path thevenvpython stub.E.g. on Windows:
So how does this work?
The
.exefiles in.venv\Scripts(Windows) or.venv/bin(Linux) are small executables which check their own names and directory to discover the correct venv location, and python version. They then launch the real Python, Pip etc, with the correct environment.The situation on Linux etc is very similar, except that the directories are named differently, e.g.
.venv/bininstead of.venv/scripts.