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.
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 | |||||
2021 | |||||
2020 SP1 | |||||
2020 | |||||
2019 SP1 | |||||
2019 | |||||
2018 SP1 | |||||
2018 |
Compatible
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:
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
Use the following command to install Python 2.7.
su cd /usr/src wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2 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/libpython2.7.so /usr/lib ln -s /usr/src/Python2.7.5/lib/libpython2.7.so.1.0 /usr/lib ln -s /usr/src/Python2.7.5/bin/python2.7 /usr/local/bin /sbin/ldconfig -v
Use the following command to install Python 3.6.
su cd /usr/src wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz 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/libpython3.6m.so /usr/lib64 ln -s /usr/src/Python-3.6.3/libpython3.6m.so.1.0 /usr/lib64 ln -s /usr/src/Python-3.6.3/python /usr/bin/python3 /sbin/ldconfig -v
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.
Windows® is registered trademarks of Microsoft Corporation in the United States and/or other countries.
Python® is a registered trademark of the PSF.