10-03-2018 08:41 AM
Hi,
I have kind of a similar question!
I'm trying to send cluster data from labview to python through python node, but so far I have no clue how labview send cluster data to python (I mean in what format or form), have tried many python parsing options but still getting an error
LabVIEW: (Hex 0x687) There was an error in executing the specified function. Python returned the following error: <class 'TypeError'> bad argument type for built-in operation
10-04-2018 10:52 AM - edited 10-04-2018 10:59 AM
You can treat LabVIEW clusters in Python as Tuples and access their elements accordingly. Please see the below example where we multiply two integers from a cluster using a Python function.
It's worth noting that the Python Node supports the following data types:
- Numerics
- Arrays, including multi-dimensional arrays
- Strings
- Clusters
Python Node
http://zone.ni.com/reference/en-XX/help/371361R-01/glang/python_node
10-13-2018 02:52 PM
I've discovered another slight weirdness with the LabVIEW support for Python. The latest version of Ananconda Python has been switched to Python 3.7 - so on a newly installed laptop, I have Ananconda3 in C:\ProgramData\Ananaconda3, and within that I created a python3.6 environment which lives in C:\ProgragramData\Anaconda3\envs\py36\.
Now I know that I need to make sure that LabVIEW 2018 can find the python install in the path, and I see in the documentation that LabVIEW supports 2.7 and 3.6 only, so I keep all other bits of Ananconda out of my PATH envornment variable and put C:\ProgramData\Anaconda3\envs\py36 at the start of the part, so the 3.6 Python is the first python to be found. I've made sure that everything is 64bit and opening up a command window does indeed give me 64bit Python 3.6 when I run python.exe.
Trying to use the LabVIEW Python nodes fails on the Open Python Session node with an Error 1671 "Error Creating Host Process". This is before trying to do anything in terms of calling a script. Telling LabVIEW to open other Python versions (e.g. 3.7,3.5,36) all give errors which seem sensible - not found or not supported python versions.
Changing the path to pint to the 'base' Python environment (i.e. 3.7 in C:\ProgramData\Anaconda3\) and telling LabVIEW to open a session to the allegedly unsupported 3.7 seems to work just fine....
Which is all fine, but there seems to be a serious lack of documentation about how to actually configure things to make LabVIEW and Python talk to each other...
10-18-2018 09:07 AM
I had too a hard time. Installed various things...
For me the best solution is: Get Python 3.6.0 from https://www.python.org/
Set the System variables Path to the directory
( normally C:\Users\User\AppData\Local\Programs\Python\Python36-32)
go to cmd and check the version with command: python --version
and then install packages which are needed like aurelian explained
1. in the command prompt write "cd C:\Users\user\AppData\Local\Programs\Python\Python36-32\Scripts" so all the other command will occur in this folder.
2. type "pip install numpy" and the other libraries that you want. I installed matplotlib, scipy, scikit-learn, pillow, pandas, tensorflow (compatible just with Python 64bits) and keras.
Thats what worked for me.
10-18-2018 09:17 AM
In fact some more testing showed that numpy in the current Anaconda Python distribution based on 3.7 doesn't load when called from the Python Node - which is a little annoying as it means I now have to keep a miniconda based 3.6 install of Python around for LabVIEW on top of the "full-fat" Anaconda distribution for coding in Python.
02-02-2019 12:47 PM
@gb119 wrote:
In fact some more testing showed that numpy in the current Anaconda Python distribution based on 3.7 doesn't load when called from the Python Node - which is a little annoying as it means I now have to keep a miniconda based 3.6 install of Python around for LabVIEW on top of the "full-fat" Anaconda distribution for coding in Python.
Could you create a conda env with 3.6 in it? Instead full installation of Miniconda?
02-02-2019 01:17 PM
I did try that but it gave some errors - I'm afraid I can't remember now what the problem was - something on the lines of it not being able to find the correct dll (even after I fixed the path). In the end it seemed easier to just go with miniconda and a 3.6 install. Hopefully NI will update 2019 to work with 3.7 as well.
11-13-2019 09:00 PM
Hello !Can i ask you a question?
I write a vi as follows,but it always send me this error.i don't konw how to deal it.could you tell me how to do? If my python has something wrong?
12-03-2019 06:13 AM
Hello, did you tried to return an array? When I use the initial Python3.6, it works well. However, when I install numpy, even I do not import it, array still can not be returned.
12-03-2019 07:26 AM
I think you have to convert the arrays back to lists before you return them to LabVIEW. It would be nice if LabVIEW's Python node supported numpy arrays (since numpy is the defacto standard in the Python world for handling numerical data) - it would also be nice if Python > 3.6.6ish worked 🙂