LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with LabPython - unable to get it running...

Solved!
Go to solution

Colleagues,

 

I've got small trouble with LabPython...

I have download LabPython from here: http://labpython.sourceforge.net/ (latest ver. 1.2 from 15 Jan 08)

Then Python from here: http://www.python.org/ (latest ver. 2.6 from 01 Oct 08)

Now trying to run examples, and every time I have error 1046 from PYTHON New Session (LabVIEW:  LabVIEW cannot initialize the script server.  Ensure the server software is installed.).

 

I'm missing something? This is my first experience with Python...

 

Andrey.

 

0 Kudos
Message 1 of 14
(10,222 Views)
Solution
Accepted by topic author Andrey_Dmitriev

Ah, got it.

 

The problem was that LabPython is incompatible with Python 2.6. Python25.dll is required (called from lvpython.dll).

I have just copied Python26.dll to Python25.dll and now it works. Will download and install previous version...

 

Andrey.

 

Message 2 of 14
(10,212 Views)

Andrey Dmitriev wrote:

Ah, got it.

 

The problem was that LabPython is incompatible with Python 2.6. Python25.dll is required (called from lvpython.dll).

I have just copied Python26.dll to Python25.dll and now it works. Will download and install previous version...

 

Andrey.

 


Actually this is not exactly correct. LabPython does link dynamically to pythonxx.dll. Bydefault the last released version does link to python25.dll as you have found out. But you can set a different DLL to be used. For that you have to make sure that you do not currently have any LabPython VIs loaded.

 

Then run the PYTHON Set Server Path.vi with the DLL name alone if you have installed one of the latest python releases that install the DLL into the system directory or the explicite path to the Python DLL if you want a particular Python DLL used. After that LabPython should use this new DLL instead of python25.dll.

 

It does this by adding an entry to labview.ini and if you ever should intend to create an application you just have to make sure to copy that line into your application ini file to make it work with the desired python version. 

 

Rolf Kalbermatter 

Rolf Kalbermatter
My Blog
Message 3 of 14
(10,195 Views)

 Thank you, Rolf. Your answer is exactly what I needed. This explained all. 

 

One more question - about deployment. What else needed for the builded application? I mean - is it enough to include pythonxx.dll only, or I need to install complete python on the target machine? For me, of course much more convenient to include few dlls into project instead of calling external additional installer.

 

Thank you, 

Andrey.

 

0 Kudos
Message 4 of 14
(10,167 Views)

Andrey Dmitriev wrote:

 Thank you, Rolf. Your answer is exactly what I needed. This explained all. 

 

One more question - about deployment. What else needed for the builded application? I mean - is it enough to include pythonxx.dll only, or I need to install complete python on the target machine? For me, of course much more convenient to include few dlls into project instead of calling external additional installer.

 

Thank you, 

Andrey.

 


If you only want to use the Python core, the DLL should be all you need, at least it was like that until 2.5. Since Windows will attempt to load a DLL referenced by name only (thus not with full name) from the application directory first you can also put that DLL into the same folder as your application.

 

However most users usually do run various Python extensions such as numpy, sockets, ssl, sqlite, tcl, etc, etc at some point inside their Python scripts and to get that installed right you really have to go with the official Python installer. Otherwise you have to deal with the installations of those Python modules, DLLs and all their dependencies at the right place too, and that is IMHO way to  much hassle.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
Message 5 of 14
(10,163 Views)
I have followed the instructions here and also looked at other posts and was not able to make this code work. I did run the PYTHON Set Server Path.vi and set it to python22.dll. I keep getting this error Error 1050 occurred at PYTHON Execute Script__ogtk.vi->adiabaticlwc_python.vi:exceptions.ImportError, No module named optparse

0 Kudos
Message 6 of 14
(9,604 Views)

You try to import a Python module called "optparse". This is either not installed or your Python Path does not contain the path to where it is installed.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 14
(9,581 Views)

How do you set the python25.dll path using Python Set Server Path.vi? I have more recent versions installed, causing LabVIEW to default to the wrong library. Below is an image of how I currently have it set up.

Server Path.PNG

0 Kudos
Message 8 of 14
(8,422 Views)

You can't do that like this. The Python wrapper DLL references and loads  the according Python DLL at load time so once you open the VI the Python DLL is already loaded and your Python Set Server Path VI has no effect whatsowever. The only thing it really does is adding an ini entry to the labview.ini file. You need to make sure to run Python Set Server Path.vi while no other LabPython VI is loaded.

 

This VI is not really meant to be used inside an application but only once after you installed a new Python version to make LabPython use that new version in the future.

 

Also since you want to reference a DLL inside the Windows system Folder it is enough to just specify the DLL name without path information, although that shouldn't cause harm either.

 

Rolf Kalbermatter
My Blog
Message 9 of 14
(8,369 Views)

 


@rolfk wrote:

You can't do that like this. The Python wrapper DLL references and loads  the according Python DLL at load time so once you open the VI the Python DLL is already loaded and your Python Set Server Path VI has no effect whatsowever. The only thing it really does is adding an ini entry to the labview.ini file. You need to make sure to run Python Set Server Path.vi while no other LabPython VI is loaded.

 

This VI is not really meant to be used inside an application but only once after you installed a new Python version to make LabPython use that new version in the future.

 

Also since you want to reference a DLL inside the Windows system Folder it is enough to just specify the DLL name without path information, although that shouldn't cause harm either.

 


 

I initiliazed the server as follows:

Server Path 2.PNG

It was made as a seperate 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

 

0 Kudos
Message 10 of 14
(8,335 Views)