> I create a pyd File named "testPyd" with boostPython,and then I import the 
> testPyd module into "test.py", it works perfect!
> But when I embeded the python interpreter into my C++ project and run the 
> "test.py", it comes out a "ImportErr: no module named testPyd".
> It has confused me for two days and I googled for long time,but I can't find 
> the answer!
> Anybody here can help me ?
> Thank you!
> 

        Ah, that sounds familiar.  I have a small bit of experience with Boost. 
 I could be wrong, because once you start mixing it up with Boost all sorts of 
weird things can happen (especially on a MS compiler, because no one tests for 
Windows, let alone a pay-for compiler) but my experience has shown that if you 
get that specific import error, what it actually means is just that the PYD 
import failed for ANY reason.  It has nothing to do with the name or that the 
PYD couldn't be found.  Just that somewhere, at some time during import, it 
failed to fully load.

        In my use a lot of times it was either that a DLL that module depended 
on wasn't in the path, or my favorite kicker, that some compile/link flags 
between the PYD and the Python interpreter don't match well enough.  (Usually 
from mixing debug and release builds together.)

        From what I've seen anyway, the Python interpreter really doesn't like 
being built in a traditional debug mode, so I always do a release build of it.  
It's a little inconvenient, but in the linker flags you can still set your PYDs 
to generate debug information even in release builds, so you can still run the 
debugger on them when you attach to the process of the python interpreter EXE.  
And especially be sure to use the RELEASE runtime library flag (such as /MD) 
instead of the debug flag (such as /MDd).

        That's as much as I know anyway.  Though depending, if you add any new 
templates/libraries into Boost (such as for NumPy ndarray), you also may need 
to use the /DBOOST_ALL_NO_LIB compiler macro on an MS compiler because MS 
doesn't adhere to template standards correctly and you often end up with 
multiply-defined functions if you don't use that macro.  If I remember 
correctly.  (It's been a while.)

        That and you may be picking up variable length arrays out of your 
teeth, replacing chunks of code with the use of new and delete operators.  No 
one tests for Microsoft and the MS compiler is way behind in adhering to C/C++ 
standards, and VLAs pop up a lot.

        Hopefully something in all of this helped.  Boost can be ... daunting.  
I get it, in theory.  But in practice it often hurts my head.  ;)

Sincerely,
Arah Leonard
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to