From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with LabPython - Setting up the Python Server

Solved!
Go to solution

I initialized the server as follows:

Server Path 2.PNG

It was made as a separate VI, and I ran it before opening any other VI's.

 

The server initializes, but I am unable to obtain variables from the code being computed. Below is a very simple program, along with its error code.

Simple Sum.PNG

I was able to run such code previously. The variable for the Get Data VI is identified as an integer.

Attached is the VI shown above

Message 1 of 10
(10,196 Views)
Solution
Accepted by shultz58

You forgot one thing.

 

Simple%20Sum[1].png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 2 of 10
(10,171 Views)

LabPython version 4.0.0.4 seems only to work with Python2.7.3/32bit, on Win7/64bit and LabVIEW2011 32bit.


and not with Python3.2.3/32bit. Those are the most recent releases. The 64 bit versions of Python does not work with labVIEW32bit.

 

The error code is the 1046 "LabVIEW cannot initialize the script server.  Ensure the server software is installed."

 

And a few comments on the vi "PYTHON set Server Path_ogtk.vi": It has a string input which according to the front panel (its missing a help string!) is

possible values : PythonServer
                  ArrayModule

Why use a string to select between two possible values? A properly crafted enum would be much simpler and less error prone for the user.

 

The quick help window labels the values for this input as "token (empty: PythonServer)". This is non standard and consequently - misleading syntax. The Empty keeword is implicty (default), so a standard syntax would be

token ("PythonServer")

 

By the way, the standard python27.dll location seems to be "C:\Windows\SysWOW64\python27.dll" and not C:\Windows\System32\python27.dll. At least in my installation.

0 Kudos
Message 3 of 10
(9,803 Views)

LabPython was developed more than 10 years ago by me and has not received any significant work anymore. I have moved on to other things and do not intend to work on LabPython. It's all on sourceforge so you are very free to work through all the details and adapt it to the newest Python version, improve the documentation and what else. Just be aware that Python upgrades rather frequently and always uses a different DLL name with each new version. That is why there is a function like PYTHON set Server Path function to point the library to the actual Python DLL implementation. But LapPython uses a pure 32 bit interface DLL and you would have to port it all to 64 Bit in order to interface to 64  Bit Python. A 32 Bit application can only load 32 Bit DLLs and that DLL can again only load 32 Bit DLLs. Same for 64 Bit applications which only can load 64 Bit DLLs and so on.

 

Also LabPython interfaces directly to the Python C API. While it seemed to have worked for all major 2.x releases Python specifically reserves the right to change the API between every version and makes no guarantee that it stays compatible, or doesn't drop entire functions between versions. So I would be a little careful about trying to point LabPython to a 3.x version of Python, as according to the Python developer page, they don't even guaranteed compatibility between the various 2.x versions.

 

Also the path Python gets installed changes between versions too and is also dependant on your OS version.

 

When you point LabPython to a 64 Bit Python installation, the 32 BIt LabPython DLL tries to load that DLL, but Windwos refuses that as it is not compatible to the environment of the calling process.

 

Also it's not clear if NI didn't change the script server interface. I know they use internally a newer version for their latest script servers but kept support for the older interface that LabPython uses, but that support may have been axed in the 64 Bit version of LabVIEW.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 10
(9,779 Views)

Hi Rolf,

I have similar problem. Do not know how to fix it as i'm a beginner to Lab python.

I have installed Python 2.7.3 w64 bit in my PC and have been using that for my software test development.

now i was asked to provide a GUI for the test script that i had already created with python. Thought Labphython would be a good option.

unfortunetely i got struck with some problem after the installation of labpython, i didnt have any problem during the installation though.

but when i tred to run one of the example PYTHON+Test+Script+Node.vi , it says "LabVIEW:  LabVIEW cannot initialize the script server.  Ensure the server software is installed. in PYTHON+Test+Script+Node.vi"

I tried updating the server but as you mentioned since its 64 bit, though its there in "C:\Windows\System32\python27.dll" , it is not displaying when i tred to choose the dll from that specific folder.But it has updated the *.ini file.

did check the Labview.ini and its updated with the right value "PythonServer=python27.dll"

 

Could you please help me to make it work or if you have any other suggestions to use the labview with python script?

 

0 Kudos
Message 5 of 10
(9,532 Views)

LabPython is compiled as 32 Bit DLL. It can only load the 32 Bit version of Python. In order for LabPython to be able to use 64 Bit Python you would have to recompile the LapPython DLL as 64 Bit version and also use 64 Bit LabVIEW. The entire chain of calling application, and all called DLLs needs to be the same bitness.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 10
(9,515 Views)

LabPython was compiled as 32 Bit DLL and as such can only connect to 32 Bit Python. If you want to use 64 Bit Python you have to recompile the LabPython DLL as 64 Bit DLL and also use 64 Bit LabVIEW.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 10
(9,514 Views)

Thankyou for your information. the problem is fixed after i installed the 32 bit version of python 2.7.5 version.Smiley Happy

 

Regards,

Nancy

0 Kudos
Message 8 of 10
(9,497 Views)

Hi,

 

I'm having the same problem with labpython. I'm probably just missing a step in one of the solutions already posted, but I need help seeing what it is, exactly. As far as I can tell, the structure of my .vi already looks identical to the accepted solution and I have got the python27.dll in C:\Python27\, running 32-bit python with 32-bit LabVIEW 2013.

 

main.png

config.png

 

After reading through an earlier thread I have also separated out the python server configuration into a separate VI which executes before everything else. The whole VI initialises, but then fails with an error 1048 at PYTHON Get Float Data_ogtk.vi : "LabVIEW failed to get variable from the script server".

 

So what am I doing wrong?

---------------------------------------------------------------------
LabVIEW 2013, Windows 7

He who asks the question is a fool for five minutes; he who does not ask the question remains a fool forever.
0 Kudos
Message 9 of 10
(8,817 Views)

Did you read the second post in this thread? Look at the red circle in that image!

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(8,799 Views)