Use Python Virtual Environments with LabVIEW

Updated May 6, 2023

Reported In

Software

  • LabVIEW
  • Enthought Python Integration Toolkit for LabVIEW

Programming Language

  • Python

Other

  • Anaconda (Conda) Environment
  • Virtualenv
  • Venv (Python 3+)

Issue Details

How can LabVIEW call code built in a Python virtual environment? I've used Python Integration Toolkit by Enthought which gives you the option, but the LabVIEW-native Python Node seems to use a different Python environment and I can't seem to change it.

Solution

Python installed within virtual environments cannot directly communicate with LabVIEW using the Python Node with LabVIEW 2021, or older. This is due to the way the environment wraps the Python interpreter, making LabVIEW unable to find the interpreter installation to make the necessary calls.

The supported Python environments, installed from The Python Software Foundation are:

  • LabVIEW 2018 to 2020:
    • Native Python 2.7 and 3.6.
  • LabVIEW 2021 and 2022:
    • Native Python 3.6, 3.7, 3.8, and 3.9.
    • Note: Support for Python 2.7 is deprecated.
  • LabVIEW 2023Q1:
    • Native Python 3.6 through 3.10
    • Python Virtual Environments using Open Anaconda/Venv Python Session VI.

 

Additional Information

 
  • Unsupported Python versions may work with the LabVIEW Python functions, NI recommends using supported versions of Python only.
  • Ensure that the bitness of Python corresponds to the bitness of LabVIEW installed on the machine.
  • Use the Python Node to integrate Python Code in LabVIEW using code created in supported Python versions.
  • As of June 2, 2020, the Python Integration Toolkit by Enthought is at end of life. For information on supported environments with the Python Integration Toolkit by Enthought, see the specifications on their website or contact Enthought support.