LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
CL_eisenwr

Support Python Virtual Environments

Status: New

I would be helpful if the Python nodes supported Python Virtual Environments. One of the powerful features of Python is able to setup multiple separate environments on a single computer, it would be LabVIEW's Python integration could also leverage this. TestStand already does have this capability, so hopefully it could be quickly/easily leveraged into LabVIEW. 😁

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
7 Comments
TurboPhil
Active Participant

If the LabVIEW nodes are going to be of any real use, I think this is a hard requirement. 

LDBM
Active Participant

strongly agree.

 

tfasquelle
Member

In LabVIEW 2021 you can specify python.exe path as an input of the "open python session" vi, allowing you to use a venv or an embedded python.

CL_eisenwr
Active Participant

tfasquelle,

I had tested in the 2021 beta and it did not work out of the box at the time. Specifically I had tried a venv virtual environment and I had to copy a DLL into the Scripts folder for LabVIEW's Open Python to work with that path. Have you tried in the released version?

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
D*
Member
Member

I have been pointing to the dll in the env (This env installed the different python version it needed, than what was in base):
C:\Users\labadmin\miniconda3\envs\my_virtual_environment\python38.dll

 

Next, the Anaconda console and "conda activate" environment activation are adding to the PATH environment variable.  These are temporary additions, and also live only within the process chain of the console window.  (One workaround is to make them permanent, but that kinda defeats the purpose,right?) However, after activation of the environment, you can call LabVIEW from that console window, e.g.:

(my_virtual_environment) C:\>"C:\Program Files\National Instruments\LabVIEW 2021\LabVIEW.exe"

 

and then things will work.

 

It is sure ugly to launch LabVIEW from an Anaconda window. 

CL_eisenwr
Active Participant

I had tried launching LabVIEW from the with the python venv created virtual environment, however it is not working like Anaconda did for D*. I cannot seem to import a module that is only installed in the virtual environment.

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
D*
Member
Member

"cannot seem to import": does that mean it can't find them?

 

Does LabVIEW see the environment paths?

 

If you run from System Exec.vi:

D_0-1642525355721.png

 

you should see your environment's paths.