From astaley at berkeley.edu Fri Jul 4 08:14:41 2008 From: astaley at berkeley.edu (Aaron Staley) Date: Thu, 03 Jul 2008 23:14:41 -0700 Subject: [capi-sig] importerror: no such file or directory when calling some functions in my C code Message-ID: <486DBFD1.6010307@berkeley.edu> I have been writing a python C++ extension that makes use of Intel's open computer vision library. I have been experiencing a bizarre problem. When I attempt to run my module: >>> import cvdemo Traceback (most recent call last): File "", line 1, in ImportError: No such file or directory I have found though that this will only occur when my c++ actually makes a call to opencv functions. If I comment all of those functions out, the module will be correctly imported (and I can execute all functions within it). Literally, everything works fine until a line like: cvDestroyWindow("result"); or: cvNamedWindow( "result", 1 ); or: matrix= cvLoad( matrix_name, 0, 0, 0 ); is in the code. Given how lacking in information python's import error is, I have no idea what is going on here. No compile errors are given either. Please advise, Aaron Staley From astaley at berkeley.edu Fri Jul 4 20:22:01 2008 From: astaley at berkeley.edu (Aaron Staley) Date: Fri, 04 Jul 2008 11:22:01 -0700 Subject: [capi-sig] importerror: no such file or directory when calling some functions in my C code Message-ID: <486E6A49.6030800@berkeley.edu> I have been writing a python C++ extension that makes use of Intel's open computer vision library. I have been experiencing a bizarre problem. When I attempt to run my module: >>> import cvdemo Traceback (most recent call last): File "", line 1, in ImportError: No such file or directory I have found though that this will only occur when my c++ actually makes a call to opencv functions. If I comment all of those functions out, the module will be correctly imported (and I can execute all functions within it). Literally, everything works fine until a line like: cvDestroyWindow("result"); or: cvNamedWindow( "result", 1 ); or: matrix= cvLoad( matrix_name, 0, 0, 0 ); is in the code. Given how lacking in information python's import error is, I have no idea what is going on here. No compile errors are given either. Please advise, Aaron Staley From astaley at berkeley.edu Sat Jul 5 00:44:33 2008 From: astaley at berkeley.edu (Aaron Staley) Date: Fri, 04 Jul 2008 15:44:33 -0700 Subject: [capi-sig] importerror: no such file or directory when calling some functions in my C code Message-ID: <486EA7D1.8060603@berkeley.edu> I have been writing a python C++ extension that makes use of Intel's open computer vision library. I have been experiencing a bizarre problem. When I attempt to run my module: >>> import cvdemo Traceback (most recent call last): File "", line 1, in ImportError: No such file or directory I have found though that this will only occur when my c++ actually makes a call to opencv functions. If I comment all of those functions out, the module will be correctly imported (and I can execute all functions within it). Literally, everything works fine until a line like: cvDestroyWindow("result"); or: cvNamedWindow( "result", 1 ); or: matrix= cvLoad( matrix_name, 0, 0, 0 ); is in the code. Given how lacking in information python's import error is, I have no idea what is going on here. No compile errors are given either. Please advise, Aaron Staley From gjcarneiro at gmail.com Sat Jul 5 00:52:14 2008 From: gjcarneiro at gmail.com (Gustavo Carneiro) Date: Fri, 4 Jul 2008 23:52:14 +0100 Subject: [capi-sig] importerror: no such file or directory when calling some functions in my C code In-Reply-To: <486EA7D1.8060603@berkeley.edu> References: <486EA7D1.8060603@berkeley.edu> Message-ID: Try running with the program strace and analyze the output. That often helps. 2008/7/4 Aaron Staley : > I have been writing a python C++ extension that makes use of Intel's > open computer vision library. I have been experiencing a bizarre problem. > > When I attempt to run my module: > >> import cvdemo >>>> >>> Traceback (most recent call last): > File "", line 1, in > ImportError: No such file or directory > > > I have found though that this will only occur when my c++ actually makes > a call to opencv functions. If I comment all of those functions out, > the module will be correctly imported (and I can execute all functions > within it). > > Literally, everything works fine until a line like: > > cvDestroyWindow("result"); > > or: > > cvNamedWindow( "result", 1 ); > > or: > matrix= cvLoad( matrix_name, 0, 0, 0 ); > > > is in the code. > > > Given how lacking in information python's import error is, I have no > idea what is going on here. No compile errors are given either. > > Please advise, > Aaron Staley > > > > > > _______________________________________________ > capi-sig mailing list > capi-sig at python.org > http://mail.python.org/mailman/listinfo/capi-sig > -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert From astaley at berkeley.edu Sat Jul 5 03:42:29 2008 From: astaley at berkeley.edu (Aaron Staley) Date: Fri, 04 Jul 2008 18:42:29 -0700 Subject: [capi-sig] importerror: no such file or directory when calling some functions in my C code In-Reply-To: References: <486EA7D1.8060603@berkeley.edu> Message-ID: <486ED185.4060906@berkeley.edu> Thanks for the advice. After a few more hours of work, I solved the problem. Some comments: 1) It would be nice if python gave more descriptive errors when dll's fail to load. The traces were showing this error: 1042 346460 [main] python 4240 seterrno_from_win_error: /ext/build/netrel/src/cygwin-1.5.25-15/winsup/cygwin/dlfcn.cc:103 windows error 126 (DLL failed to load due to missing files) If just the system error code was printed out it would have helped a lot. 2) IE7 is a horrible program. Apparently, it has dependences on a DLL that doesn't exist in windows XP. See comments at http://techmale.com/2008/02/27/how-microsoft-caused-apache-php_mysqldll-to-failusing-vista-dwmapidll/ Gustavo Carneiro wrote: > Try running with the program strace and analyze the output. That > often helps. > > 2008/7/4 Aaron Staley >: > > I have been writing a python C++ extension that makes use of Intel's > open computer vision library. I have been experiencing a bizarre > problem. > > When I attempt to run my module: > > import cvdemo > > Traceback (most recent call last): > File "", line 1, in > ImportError: No such file or directory > > > I have found though that this will only occur when my c++ actually > makes > a call to opencv functions. If I comment all of those functions out, > the module will be correctly imported (and I can execute all functions > within it). > > Literally, everything works fine until a line like: > > cvDestroyWindow("result"); > > or: > > cvNamedWindow( "result", 1 ); > > or: > matrix= cvLoad( matrix_name, 0, 0, 0 ); > > > is in the code. > > > Given how lacking in information python's import error is, I have no > idea what is going on here. No compile errors are given either. > > Please advise, > Aaron Staley > > > > > > _______________________________________________ > capi-sig mailing list > capi-sig at python.org > http://mail.python.org/mailman/listinfo/capi-sig > > > > > -- > Gustavo J. A. M. Carneiro > INESC Porto, Telecommunications and Multimedia Unit > "The universe is always one step beyond logic." -- Frank Herbert From ideasman42 at gmail.com Wed Jul 16 16:23:18 2008 From: ideasman42 at gmail.com (Campbell Barton) Date: Wed, 16 Jul 2008 16:23:18 +0200 Subject: [capi-sig] Python File+Line from GDB? Message-ID: <7c1ab96d0807160723n72431caak1bee345f5e862a51@mail.gmail.com> Every so often I get a crash in C/C++ code cause by some function python calls. The problem is I want to know what line number+file python called before the crash, at the moment I just do this with print's, but this is tedious. Annoyingly this crash happens when the python stack is being printed but there have been other situations when I have been debugging and wanted to know the python line number+file and where there was no python error, Any hints? ---- Here is the backtrace - at #20 or #21 the info might be available. (gdb) bt #0 0x0000000000825962 in SND_Scene::DeleteObject (this=0x18032450, pObject=0x15624320) at intern/SoundSystem/intern/SND_Scene.cpp:498 #1 0x0000000000dcd3c7 in ~KX_SoundActuator (this=0x1dc45270) at source/gameengine/Ketsji/KX_SoundActuator.cpp:76 #2 0x0000000000e704e2 in CValue::Release (this=0x1dc45270) at source/gameengine/Expressions/Value.cpp:584 #3 0x0000000000e46763 in ~SCA_IObject (this=0x18b9f940) at source/gameengine/GameLogic/SCA_IObject.cpp:71 #4 0x0000000000de9408 in ~KX_GameObject (this=0x18b9f940) at source/gameengine/Ketsji/KX_GameObject.cpp:124 #5 0x0000000000d8cffa in ~BL_DeformableGameObject (this=0x18b9f940) at source/gameengine/Converter/BL_DeformableGameObject.cpp:42 #6 0x0000000000e704e2 in CValue::Release (this=0x18b9f940) at source/gameengine/Expressions/Value.cpp:584 #7 0x0000000000d981eb in CValue::SpecialRelease (this=0x18b9f940) at source/gameengine/Expressions/Value.h:239 #8 0x0000000000d9821f in CValue::PyDestructor (P=0x18b9f948) at source/gameengine/Expressions/Value.h:243 #9 0x0000000000f6da29 in _Py_Dealloc (op=0x18b9f948) at Objects/object.c:1933 #10 0x000000000102f08d in frame_dealloc (f=0x15b361c0) at Objects/frameobject.c:416 #11 0x0000000000f6da29 in _Py_Dealloc (op=0x15b361c0) at Objects/object.c:1933 #12 0x0000000000ffa421 in tb_dealloc (tb=0x5dff240) at Python/traceback.c:34 #13 0x0000000000f6da29 in _Py_Dealloc (op=0x5dff240) at Objects/object.c:1933 #14 0x0000000000ffa3a8 in tb_dealloc (tb=0x5dff1c8) at Python/traceback.c:33 #15 0x0000000000f6da29 in _Py_Dealloc (op=0x5dff1c8) at Objects/object.c:1933 #16 0x0000000000f62706 in insertdict (mp=0x1754230, key=0x5dd3790, hash=5897959712516987849, value=0x5dff0d8) at Objects/dictobject.c:416 #17 0x0000000000f62fd5 in PyDict_SetItem (op=0x1754230, key=0x5dd3790, value=0x5dff0d8) at Objects/dictobject.c:641 #18 0x0000000000f6739f in PyDict_SetItemString (v=0x1754230, key=0x11331de "last_traceback", item=0x5dff0d8) at Objects/dictobject.c:2182 #19 0x0000000000ff7897 in PySys_SetObject (name=0x11331de "last_traceback", v=0x5dff0d8) at Python/sysmodule.c:82 #20 0x0000000000ff011a in PyErr_PrintEx (set_sys_last_vars=1) at Python/pythonrun.c:1076 #21 0x0000000000fefdcf in PyErr_Print () at Python/pythonrun.c:978 #22 0x0000000000e25d88 in SCA_PythonController::Trigger (this=0x10d6b350, logicmgr=0x126e4660) at source/gameengine/GameLogic/SCA_PythonController.cpp:309 #23 0x0000000000e3b69a in SCA_LogicManager::BeginFrame (this=0x126e4660, curtime=18.244133488337447, fixedtime=0.016666666666666666) at source/gameengine/GameLogic/SCA_LogicManager.cpp:257 #24 0x0000000000dc08f4 in KX_Scene::LogicBeginFrame (this=0x1e5afca0, curtime=18.244133488337447) at source/gameengine/Ketsji/KX_Scene.cpp:1311 #25 0x0000000000e155e5 in KX_KetsjiEngine::NextFrame (this=0x183f6ed0) at source/gameengine/Ketsji/KX_KetsjiEngine.cpp:440 #26 0x0000000000d5ccc9 in StartKetsjiShell (area=0xb0087d0, scenename=0x10d4fe72 "frank_test", maggie1=0x15a56390, sipo=0x1dc8c790, always_use_expand_framing=1) at source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp:376 #27 0x0000000000628319 in start_game () at source/blender/src/space.c:543 #28 0x000000000062e852 in winqreadview3dspace (sa=0xb0087d0, spacedata=0x1fb5f2f0, evt=0x7fffbf19e150) at source/blender/src/space.c:2464 #29 0x0000000000683170 in scrarea_do_winhandle (area=0xb0087d0, evt=0x7fffbf19e150) at source/blender/src/spacetypes.c:156 #30 0x00000000006d8244 in scrarea_dispatch_events (sa=0xb0087d0) at source/blender/src/editscreen.c:598 #31 0x00000000006d9c00 in screen_dispatch_events () at source/blender/src/editscreen.c:1224 #32 0x00000000006da67a in screenmain () at source/blender/src/editscreen.c:1508 #33 0x00000000004f45ae in main (argc=6, argv=0x7fffbf19e5a8) at source/creator/creator.c:820 From rhamph at gmail.com Wed Jul 16 18:32:09 2008 From: rhamph at gmail.com (Adam Olsen) Date: Wed, 16 Jul 2008 10:32:09 -0600 Subject: [capi-sig] Python File+Line from GDB? In-Reply-To: <7c1ab96d0807160723n72431caak1bee345f5e862a51@mail.gmail.com> References: <7c1ab96d0807160723n72431caak1bee345f5e862a51@mail.gmail.com> Message-ID: On Wed, Jul 16, 2008 at 8:23 AM, Campbell Barton wrote: > Every so often I get a crash in C/C++ code cause by some function python calls. > The problem is I want to know what line number+file python called > before the crash, at the moment I just do this with print's, but this > is tedious. > > Annoyingly this crash happens when the python stack is being printed > but there have been other situations when I have been debugging and > wanted to know the python line number+file and where there was no > python error, > Any hints? Misc/gdbinit, pystack command -- Adam Olsen, aka Rhamphoryncus From franco.dirosa at baesystems.com Fri Jul 18 19:54:18 2008 From: franco.dirosa at baesystems.com (DiRosa, Franco (US SSA)) Date: Fri, 18 Jul 2008 13:54:18 -0400 Subject: [capi-sig] How do you create a Python class and its instance using only the Python C/API... Message-ID: <76562E5779762B438648F90E9D28ED5610FA7E1A@blums0013.cs.na.baesystems.com> I've embedded Python into a C++ application under the Windows operating system. It uses Python as the scripting language to extend the Windows Application thus making it more configurable. Everything works great but I want the stderr to be redirected to a window I have up in my windows app. I noticed by stepping thru the Python code that there is a case where it looks for a "write" attribute object which if found will pass the text to (PyFile_WriteObject). That would work great but I need to create this object that exposes this "write" attribute from within my windows application code in C++ thus I need to use the Python C/API to do it. Any help on how to basically write a python class with a "write" function in it using nothing only but the Python C/API would be greatly appreciated. Thank you, Franco. From gjcarneiro at gmail.com Sun Jul 27 19:56:37 2008 From: gjcarneiro at gmail.com (Gustavo Carneiro) Date: Sun, 27 Jul 2008 18:56:37 +0100 Subject: [capi-sig] Announce: PyBindGen 0.9 released Message-ID: PyBindGen is a Python module that is geared to generating C/C++ code that binds a C/C++ library for Python. It does so without extensive use of either C++ templates or C pre-processor macros. It has modular handling of C/C++ types, and can be easily extended with Python plugins. The generated code is almost as clean as what a human programmer would write. It can be downloaded from: http://code.google.com/p/pybindgen/ Bug reports should be filed here: https://bugs.launchpad.net/pybindgen Special thanks to Roman Yakovenko (lots of help with pygccxml) and Mathieu Lacage (API suggestions, documentation writing). === pybindgen 0.9 === - Fix GCC 4.2 compilation warnings; - Works with some GCCXML 0.9/cvs snapshots (tested with 2008-04-20), in addition to stable 0.7; - Support for overloaded virtual methods; - Add 'ignore' annotation support, allowing to ignore functions and methods; - Generally work hard to make sure the generated code at least always compiles, even if we have to disable generation of certain wrappers; - Add support for protected methods and constructors; - Preliminary support for templated classes/methods/functions; - Add more type conversions, such as uint64_t and uint16_t; - Support implicit conversions also for pass-by-reference parameters; - Add supported for nested (i.e. defined inside a class) enums and classes; - Add support for adding manually written custom method or function wrappers; - Split the gccxmlparser.ModuleParser.parse() method into several smaller methods, to allow greater customization and flexibility; - Add support for customising C++ class instance creation code; - Much improved support for wrapping pure C code; - Support std::ostream << myobject mapped as str(myobject) (Mathieu Lacage) - Support default values in parameters; - More intuitive API (thanks Mathieu Lacage for feedback) - Support generation of a Python pybindgen script from scanned API; - Support splitting of generated python script and/or C/C++ module into several files; - Lots of small bug fixes, and other features I probably forgot; - New tutorial (thanks Mathieu Lacage), and API docs. -- Gustavo J. A. M. Carneiro INESC Porto, Telecommunications and Multimedia Unit "The universe is always one step beyond logic." -- Frank Herbert