Bossgaming099 / ctypes-opencv

Automatically exported from code.google.com/p/ctypes-opencv
0 stars 0 forks source link

exception in interfaces #38

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
From the interfaces numpy to ipl conversors I was getting an error after
creating an exe with py2exe:

C:\Python25\Lib\site-packages\biokit\demo\dist>verifier_gui_demo.exe
importing modules
imported lse
importing crossmatchmanager
importing biokit.commun.quality_control
importing Image
importing struct
importing math
importing ctypes
importing opencv
Traceback (most recent call last):
  File "verifier_gui_demo.py", line 6, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "biokit\sbin\CrossmatchManager.pyo", line 33, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "biokit\commun\quality_control.pyo", line 11, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "opencv\__init__.pyo", line 21, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "opencv\interfaces.pyo", line 93, in <module>
  File "ctypes\__init__.pyo", line 353, in __getattr__
  File "ctypes\__init__.pyo", line 358, in __getitem__
AttributeError: function 'PyBuffer_FromReadWriteMemory' not found

From this part of the interfaces:

#-----------------------------------------------------------------------------
# numpy's ndarray -- by Minh-Tri Pham
#-----------------------------------------------------------------------------

It only catches an ImportError:

except ImportError:
    pass

I added a general except and it works now. I didn't look in detail if it
was a py2exe or interfaces error.

The strange part is below:

C:\Python25\Lib\site-packages\biokit\demo\dist>python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> from_memory = pythonapi.PyBuffer_FromReadWriteMemory
>>>

So it is some kind of bug somewhere, as you may see that this didn't make
any error !

Thanks,

Original issue reported on code.google.com by kpo...@gmail.com on 13 May 2009 at 9:59

GoogleCodeExporter commented 8 years ago
Hmm, this is interesting. I've never used py2exe before. pythonapi is a handle 
in
ctypes that points to the Python API library. Below is the code in lines 
436-441 in
file ctypes/__init__.py:

if _os.name in ("nt", "ce"):
    pythonapi = PyDLL("python dll", None, _sys.dllhandle)
elif _sys.platform == "cygwin":
    pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
else:
    pythonapi = PyDLL(None)

Is there any difference between the Python API library loaded in python and the 
one
loaded in py2exe?

Original comment by pmtri80@gmail.com on 14 May 2009 at 1:02

GoogleCodeExporter commented 8 years ago
Strangely enough, I could not reproduce the bug with py2exe version 0.6.9. I 
guess it
must have been py2exe's bug.

Minh Tri

Original comment by pmtri80@gmail.com on 18 Jul 2009 at 5:01