How do I use LabVIEW to call the Python interpreter from Anaconda venv?

Updated Jan 11, 2024

Environment

Programming Language

  • Python
  • LabVIEW G

I want to leverage the packages/modules I installed via the pip in Anaconda, how do I run specific Python script using the venv created in Anaconda?

 

Essentailly, if one is not using venv, one should go with a basic 'Open Python Session' to open the python session which would call the Python interpretor from the default location; however, if we'd like to go with the venv created from Anaconda, some steps we'll need to follow.
 
  1. Please check you're using the same bitness of both LabVIEW and Anaconda (e.g., 64-bit)

  2. Specify the root folder of Anaconda using the 'Anaconda Path' terminal of the "Open Anaconda Python Session.vi" if this subVI couldn't find the root folder of Anaconda

  3. Place the "Open Virtual Env Session.vi" into the block diagram, and use the drop-down menu to select it to "Open Anaconda Pyton Session":
    image.png

  4. Before you specify the "Env name" & "Python version" of the input terminals, please do the following checks:

    1. anaoncda.png

    2. use the command conda env list in shell to check what are the valid venv options to use (base is also there, so base venv is supported using "Open Anaconda Python Session.vi")

    3. going into the venv, and use command python --version to check the python version being used in the venv

  5. Specify the corresponding "Env name" & "Python version" you learnt from the 2 steps above

  6. You're good to go!



 

Below is a simple LabVIEW example using it:
example_anaconda.png
Note: Please be aware it is the version of LabVIEW 2023 Q1 that starts supportting Anaconda and venv virtual environments with the new Open Virtual Environment Session function.