From Thursday, May 23rd (05:00 PM CDT) through Friday, April 24th (1:30 AM 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: 

Labpython unable to import copy_reg

Solved!
Go to solution

Labpython fails to import the copy_reg module and the modules that depend on it:

 

LabVIEW:  Error occurred while executing script. Error message from server: <type 'exceptions.ImportError'>, No module named copy_reg. in test.vi

 

 

The module copy_reg is there and is working fine. Importing other modules from labview seem to work fine.

 

I am using Labview 2009, python 2.6

 

Any ideas?

0 Kudos
Message 1 of 13
(6,332 Views)

Hi f28,

 

If you follow this tutorial:

 

http://zone.ni.com/devzone/cda/tut/p/id/8493

 

Are you able to run your script?

 

I need to install this package to help you figure out this problem, but can you attach the script you're trying to run? 

Message 2 of 13
(6,302 Views)
Solution
Accepted by topic author f28

The problem was that for some reason the Python interpreter inside labview messed up pythonpath and consequenty couldn't import modules some modules. I don't know how to solve the problem properly, but manually adding an entry to pythonpath from inside python script node in labview fixed the problem:

 

import sys
sys.path.insert(0, "C:\\Python26\\Lib")
import cPickle

0 Kudos
Message 3 of 13
(6,262 Views)

Smootastic wrote:

Hi f28,

 

If you follow this tutorial:

 

http://zone.ni.com/devzone/cda/tut/p/id/8493

 

Are you able to run your script?

 

I need to install this package to help you figure out this problem, but can you attach the script you're trying to run? 


I am doing something else: http://labpython.sourceforge.net/

0 Kudos
Message 4 of 13
(6,261 Views)

f28 wrote:

The problem was that for some reason the Python interpreter inside labview messed up pythonpath and consequenty couldn't import modules some modules. I don't know how to solve the problem properly, but manually adding an entry to pythonpath from inside python script node in labview fixed the problem:

 

import sys
sys.path.insert(0, "C:\\Python26\\Lib")
import cPickle


I believe I'm not really doing anything with the path in LabPython at all. That could mean that it is not setup at all for binary modules.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 13
(6,256 Views)

Has any progress been made on this?

I'm having trouble importing:

from "/usr/lib/pyshared/python2.6/cwiid.so"

like this:

-----------

import sys
path = sys.path
sys.path.append("/usr/lib/pyshared/python2.6")
import cwiid
-------

Error 1050 is returned by PYTHON Execute Script__ogtk.vi

 

Importing cwiid works fine in cli python/ipython but not in labpython.

 

I'm using labpython-1.2-2 with LV8.5 and Python 2.6 on a Linux host.

 

Thanks much,

joachim

 

0 Kudos
Message 6 of 13
(5,797 Views)

Could it be that your cwiid module references other modules that the Python engine can't locate? And usually you extend the path for directories containing modules, not with the module itself. The import directive tells Python to search for such a module in any of the directories named in the syspath (and I believe possibly other paths).

 

And since you try to load a binary shared library module, your system would need to be setup in such a way that it allows for the LabVIEW process to access any possible dependencies this module may have, which is completely beyond python but entirely an issue of your system setup.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 13
(5,783 Views)

>And since you try to load a binary shared library module, your system would need to be setup in such a way that it allows for the LabVIEW process to access any possible dependencies this module may have, which is completely beyond python but entirely an issue of your system setup.

 

It seems like this could be the case, however, with that dependency being the lib that defines: 'PyExc_ValueError'

A more detailed error message:

PYTHON Execute Script__ogtk.vi->pythonPlay.vi:<type 'exceptions.ImportError'>, /usr/lib/pyshared/python2.6/cwiid.so: undefined symbol: PyExc_ValueError

 

However, I actually tried exporting sys.path from ipython, where the import cwiid works fine, and sys.path.append'ing that to the sys.path withing labpython, and i still came up with the same error from above.

Are there any known issues with labpython+python2.6+linux? I have to manually run the labpython vi's as the JKI installer wasn't working for me, does the VI package manager do anything more than resolve the dynamic pattele depenancies? Note vanilla python code runs just fine.

 

Note cwiid.so is a binary python lib for accessing some fun hardware, which has been implimented in c/c++.

 

thanks again!

 

0 Kudos
Message 8 of 13
(5,774 Views)

Well this looks like a catch 22. Something goes wrong while Python tries to load that module and when it executes the Exception handler it fails to find the PyExc_ValueError function. It could be that this symbol is there because the module was really created for a different Python version that supports this function but since it is not triggered in your normal stock Python setup this error never gets encountered.

 

To sum it up: We have probably two errors here: The first happens when trying to load the binary module, and the second is then caused when the exception handler tries to access some symbol, overwriting the error cause of the first, so we don't even see that. It all is making this rather tricky to diagnose without running all the stuff myself but that is currently beyond my intentions, since setting it all up would take some considerable time.

 

While I have heard some things that could go wrong with the various Python versions, there is nothing known to me that would completely prevent LabPython to work with Python 2.6.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 13
(5,766 Views)

Sorry to have to bring up this tread again. I'm new to python and I ran into the similar problem:

 

<type 'exceptions.ImportError'>, No module named direct.showbase.ShowBase.

 

The direct.showbase.ShowBase is from Pand3D (a 3d game extension/library), it has a .pth file inside the python (v26) directory to direct the path to where the pand3d/bin is.

 

I can run their demo with the "system exec.vi". So thout kwoning exactly what I was doing, I add this as described above to the top of a do nothing .py and that didn't pass.

 

import sys
sys.path.insert(0, "D:\Panda3D-1.7.2\bin")


from direct.showbase.ShowBase import ShowBase

 

Should the labpython use the exiting python to excute so that python itself should be able find the pand3d library using the .pth file?

 

0 Kudos
Message 10 of 13
(5,553 Views)