Jump to content

LabPython 1050 error shown when import sklearn library


Recommended Posts

I have installed LabPython successfully few days ago. My goal is to experiment the possibility of calling machine learning library from python into the labview environment. So I want to run a LabPython script node that will read two local csv files for the inputs of random forest classifier. The output of the python script is the final predicted class in string format.

What I did to make this work: I have set the server path to where my python27.dll located. The script is running fine until it comes through machine learning library. It ran but struck forever to run. I can ran this exactly same code in my cmd command. 

I believe the issue rises with calling the machine learning library. Is there anyway that I can get around with this or suggest a better way to do without python script node? 

Thank you,

AL 

Labview 2015 32bits

python 2.7 32 bits

windows 10 

1050 error.PNG

script.PNG

Link to comment

Well, the screenshot you showed implies that Python threw a Syntax Error exception - although I can't immediately see why. There are a couple of issues that I can see in your code though:

1) You've got several Windows style paths quoted in strings there, but \ in Python is an escape character - to include \ in a string you need to either do "C:\\Python27\\Lib" or else use a raw string r"C:\Python27\Lib"

2) There is a major limitation to do with thread safety between Python and LabVIEW - LabVIEW is intrinsically multi-threaded and some Python libraries - such as numpy - are not. This can lead to seemingly random crashes in LabVIEW - so not your current problem, but likely to become one... There's been quite a bit of discussion in various threads here on this problem by folk who know more than me about the internals of both LabVIEW and Python....

 

(and I've just spotted, does np.loadtxt close files when passed an open filehandle - if not then you'll be leaving files left open by your script.)

Edited by gb119
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.