Integrating Python Code in LabVIEW

Información general

You can integrate code developed in Python® from LabVIEW by using the LabVIEW Python functions. The LabVIEW Python Node provides native capability to intuitively call a Python script from a LabVIEW Block Diagram. It uses LabVIEW primitives, providing a way to interoperate between the languages with low latency.


LabVIEW and Python Compatibility

Use the following table to determine which version of Python is compatible with your LabVIEW version. Although unsupported versions might work with the LabVIEW Python functions, NI recommends using supported versions of Python only.

Note – this functionality was introduced in LabVIEW 2018 and is not available in previous versions.

LabVIEW Version Python Version
3.9 3.8 3.7 3.6 2.7
2022 Q3  
2021 SP1  
2020 SP1      
2019 SP1      
2018 SP1      


Installing Python for Calling Python Code

Installing Python Shared Libraries

You must install Python to use the LabVIEW Python functions; and to run the Python code, LabVIEW requires the Python shared libraries in the system path. Follow steps for your operating system to add the Python shared libraries to the system path.

Before you begin:

  • Use the LabVIEW and Python Compatibility table to determine which supported version of Python to install.
  • Ensure that the bitness of Python corresponds to the bitness of LabVIEW installed on the machine.


To install the Python shared libraries to your Windows® machine, add the directory for your Python version to the system path.


Install Python by building from the source to ensure that the libpython shared object is available in the standard search directories.

To begin, find a Python release that is compatible with your OS and your version of LabVIEW.

Then, use the following command structure to install Python. Explanation and example are below.

su cd /usr/src wget <Python Download FTP URL> tar -xvjf <Python download zip folder> cd <Python version> ./configure --prefix=/usr/local/<Python version> --with-threads --enable-shared make install altinstall ln -s /usr/src/<Python release version>/lib/<Python library>/usr/lib ln -s /usr/src/<Python release version>/lib//<Python library>.1.0 /usr/lib ln -s /usr/src/<Python release version>/bin/<Python version> /usr/local/bin /sbin/ldconfig -v
  1. su cd /usr/src – Enables super user and changes the directory to /usr/src.
  2. wget <Python Download FTP URL> -  Downloads the source code for the Python version using ftp. The file extension for the download will be in the form a zip file (ex: .tar.bz2).
  3. tar -xvjf <Python download zip folder> - This will unzip the file to Python download folder.
    • The folder name will be the end of the URL.
    • Example Python download zip folder: Python-2.7.5.tar.bz2
  4. cd <Python release version> -  Change directory to the newly created folder in step 3.
    • Example Python release version: Python-2.7.5
  5. ./configure --prefix=/usr/local/python2.7 --with-threads --enable-shared make install altinstall – This is the main command which will build the Python executable from the source. This also ensures that the shared object (.so) file is also generated via the option –enable-shared .
    • Python version format: python2.7
      •  The format of this command is only the Python version and not its specific release (e.g. Python x.y, not Python x.y.z).
  6. ln -s /usr/src/<Python release version>/lib/<Python library>/usr/lib ln -s /usr/src/<Python release version>/lib//<Python library>.1.0 /usr/lib ln -s /usr/src/<Python release version>/bin/<Python version> /usr/local/bin - These commands are creating symbolic links for the library files created in the /usr/lib and /usr/local/bin directories.
    • Example Python release version: Python2.7.5
    • Example Python library name:
    • Example Python version: python2.7
  7. /sbin/ldconfig -v – This final command rebuilds the shared library cache, rectifying the added symbolic links from step 6.


Example Command: Python 2.7

Use the following command to install Python 2.7.

 su cd /usr/src wget tar -xvjf Python-2.7.5.tar.bz2 cd Python-2.7.5 ./configure --prefix=/usr/local/python2.7 --with-threads --enable-shared make install altinstall ln -s /usr/src/Python2.7.5/lib/ /usr/lib ln -s /usr/src/Python2.7.5/lib/ /usr/lib ln -s /usr/src/Python2.7.5/bin/python2.7 /usr/local/bin /sbin/ldconfig -v


Example Command: Python 3.6

Use the following command to install Python 3.6.

 su cd /usr/src wget tar -xzf Python-3.6.3.tgz cd Python-3.6.3 ./configure --prefix=/usr/local/python3.6 --with-threads --enable-shared make install altinstall ln -s /usr/src/Python-3.6.3/ /usr/lib64 ln -s /usr/src/Python-3.6.3/ /usr/lib64 ln -s /usr/src/Python-3.6.3/python /usr/bin/python3 /sbin/ldconfig -v

LabVIEW Python Functions Examples

There are multiple examples from LabVIEW that demonstrate how to set up your block diagram and call your Python code.

Examples for using the Python Node are available in the LabVIEW Example Finder (found in Help >> Find Examples...) under Communicating with External Applications >> Using External Code >> Integrating Python Code.

Additional Resources

Windows® is registered trademarks of Microsoft Corporation in the United States and/or other countries.
Python® is a registered trademark of the PSF. 

Was this information helpful?