Use Python Virtual Environments with LabVIEW

Updated Jan 19, 2022

Reported In

Software

  • LabVIEW
  • Enthought Python Integration Toolkit for LabVIEW

Programming Language

  • Python

Other

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

Issue Details

How do I make LabVIEW use code built in my 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 the latest version of LabVIEW (2021). This is due to the way the environment wraps the Python interpreter, making LabVIEW unable to find the interpreter installation and unable to make the necessary calls.  

The officially supported Python environments that can communicate with LabVIEW 2018 up to 2020 are native Python 2.7 and 3.6 installed from The Python Software Foundation. LabVIEW 2021 added support for Python 3.7, 3.8, and 3.9. It maintains support for Python 3.6 but deprecates support for Python 2.7.

 

Additional Information

  • LabVIEW 2018 - 2020 supports calling Python version 2.7 and 3.6.
    • Although unsupported versions might 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.