Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Python and NI resources

Python can be used very productively alongside NI's software platform.

 

This document is a starting point to help curate resources for successfully using Python with NI software and hardware.

 

PythonStack.JPG

 

Python Resources for NI Hardware and Software

http://www.ni.com/white-paper/53059/en/

 

 

Tutorials

Python calling TestStand

https://decibel.ni.com/content/docs/DOC-35073

 

TestStand calling Python

http://www.ni.com/tutorial/8847/en/

 

Python calling LabVIEW

Calling a LabVIEW DLL - http://www.ni.com/tutorial/5719/en/

Calling the LabVIEW web server using HTTP Requests http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/build_web_service/

Calling LabVIEW through a TCP/IP connection using the LabVIEW Automation library https://github.com/ni/python_labview_automation


LabVIEW calling Python

System Exec VI

http://www.ni.com/tutorial/8493/en/

https://decibel.ni.com/content/docs/DOC-8995

LabPython  http://vipm.jki.net/#!/package/oglib_labpython

 

Python calling NI Drivers C DLLs using ctypes

http://www.ni.com/white-paper/8911/en/

 

Python calling NI Drivers with Python wrappers of ctypes created by others

https://pythonhosted.org/PyDAQmx/

https://github.com/bernardokyotoku/pyniscope

https://github.com/armstrap/armstrap-pyvirtualbench

 

 

How are you using Python with NI's platform? Any examples you'd like to share?

Joey S.
Senior Product Manager, Software
National Instruments
Comments
Ian_Phillips
Member
Member
on

Also, quite a good wrapper for calling python code from Labview is labpython. Install from VIPM

http://vipm.jki.net/#!/package/oglib_labpython

Also information in: https://decibel.ni.com/content/docs/DOC-21687

ygribel1
Member
Member
on

Thanks, Joey

Now everything in one place.

Please keep updating

JoeySpinella
NI Employee (retired)
on

Ian, I love labpython but haven't seen it working with Python 2.7.x. Do you know if there is a release that supports this?

Joey S.
Senior Product Manager, Software
National Instruments
ystoyanov
Member
Member
on

Thanks, Joey, for a great presentation on using Python with LabVIEW and TestStand.

Does it matter which version of Python is used with the NI tools, i.e. 2.7.x or 3.x?

Yuri

JoeySpinella
NI Employee (retired)
on

Yuri, great question.

I typically use Python 2.7x and made the demos using this. You should be able to use Python 3.x for most of these but may have trouble with some of the code modules (PyDAQmx, Python LabVIEW Automation).

Joey S.
Senior Product Manager, Software
National Instruments
Ian_Phillips
Member
Member
on

Hi Joey,

Sorry I haven't used LabPython in a while. I know that it works with Python 2.7.3 and Labview 2012. One known issue is that it only works in 32bit mode.

There is a discussion with known issues on the support webpage. In particular some information on redirecting output which helps debug your python code. I recommend reading.

https://sourceforge.net/p/labpython/mailman/labpython-users/?limit=250

Hope this helps

Best Regards

Ian

ystoyanov
Member
Member
on

Thanks Joey.

It will be great if PyDAQmx and Python LabVIEW Automation can be re-tooled for Python 3 eventually. What are the chances of this hapening in the forseeable future?

For the time being, your advice is to stick with Python 2.7.x for full NI tool support?

ystoyanov
Member
Member
on

Just found these - for the brave who never fear

2to3
https://docs.python.org/2/library/2to3.html

3to2

https://wiki.python.org/moin/3to2

PrimaryKey
NI Employee (retired)
on

I think it would be valuable to mention in this article about this - https://decibel.ni.com/content/docs/DOC-47034

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
ding_xing_ming
Member
Member
on

What is the data type returned by OpenCV when I call OpenCV library using Python? Can't I get it via a 3D array? why is it like this? What data type do I need to use to get it correctly?

Python Source CodePython Source CodeLabVIEW Source CodeLabVIEW Source CodeLabVIEW UILabVIEW UI