Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.04; 'interpreter': 0.04; 'compiler': 0.05; 'debug': 0.05; 'pop': 0.05; '(especially': 0.07; 'linker': 0.07; 'skip:/ 10': 0.07; 'python': 0.09; 'c/c++': 0.09; 'chunks': 0.09; 'debugger': 0.09; 'macro.': 0.09; 'mode,': 0.09; 'path,': 0.09; 'runtime': 0.09; 'windows,': 0.09; 'wrong,': 0.09; 'template': 0.11; 'subject:python': 0.11; 'library': 0.15; 'weird': 0.15; "(it's": 0.16; 'ah,': 0.16; 'boost.': 0.16; 'compiler,': 0.16; 'enough.': 0.16; 'googled': 0.16; 'hurts': 0.16; 'macro': 0.16; 'numpy': 0.16; 'operators.': 0.16; 'reason.': 0.16; 'sorts': 0.16; 'subject: \n ': 0.16; 'subject:File': 0.16; 'subject:embed': 0.16; 'subject:import': 0.16; 'replacing': 0.17; 'subject:project': 0.17; 'tests': 0.18; 'module': 0.19; 'variable': 0.20; 'to:name:python- list@python.org': 0.20; 'bit': 0.21; 'import': 0.21; '(usually': 0.22; 'flags': 0.22; "i've": 0.23; 'header:In-Reply-To:1': 0.25; '(such': 0.27; 'c++': 0.27; 'dll': 0.27; 'found.': 0.27; "doesn't": 0.28; 'run': 0.28; 'arrays': 0.29; 'lot.': 0.29; 'attach': 0.30; 'standards': 0.30; 'code': 0.31; 'file': 0.32; 'anybody': 0.32; 'could': 0.32; 'builds': 0.33; 'correctly.': 0.33; 'hopefully': 0.33; 'picking': 0.33; 'traditional': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'project': 0.34; 'especially': 0.35; 'something': 0.35; 'add': 0.36; 'really': 0.36; 'but': 0.36; 'alone': 0.36; 'received:71': 0.36; "wasn't": 0.36; 'thank': 0.36; 'charset:us-ascii': 0.36; 'correctly': 0.37; 'two': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'behind': 0.38; 'some': 0.38; 'things': 0.38; 'nothing': 0.38; 'received:10': 0.38; 'sure': 0.38; 'delete': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'release': 0.39; 'build': 0.39; 'little': 0.39; 'help': 0.40; 'end': 0.40; 'your': 0.60; 'days': 0.60; 'between': 0.63; 'times': 0.63; 'information': 0.63; 'here': 0.65; 'sounds': 0.71; 'adhere': 0.84; 'daunting.': 0.84; 'depended': 0.84; 'perfect!': 0.84; 'standards,': 0.84 From: "Leonard, Arah" To: "python-list@python.org" Subject: RE: Failed to import a "pyd: File When python intepreter embed in C++ project Thread-Topic: Failed to import a "pyd: File When python intepreter embed in C++ project Thread-Index: AQHN+RQVGX94ReWdqEuPVk5Wm3XuPZhXEuHA Date: Wed, 23 Jan 2013 16:28:58 +0000 References: <552da0d2-e744-4ce2-8204-14a7274515de@googlegroups.com> In-Reply-To: <552da0d2-e744-4ce2-8204-14a7274515de@googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.73.1.96] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 23 Jan 2013 16:29:00.0195 (UTC) FILETIME=[BFC5AF30:01CDF986] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358958543 news.xs4all.nl 6889 [2001:888:2000:d::a6]:51321 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37488 > I create a pyd File named "testPyd" with boostPython,and then I import th= e 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 f= ind the answer! > Anybody here can help me ? > Thank you! >=20 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 o= f weird things can happen (especially on a MS compiler, because no one test= s for Windows, let alone a pay-for compiler) but my experience has shown th= at if you get that specific import error, what it actually means is just th= at the PYD import failed for ANY reason. It has nothing to do with the nam= e or that the PYD couldn't be found. Just that somewhere, at some time dur= ing 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 bet= ween 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 bei= ng 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 you= r PYDs to generate debug information even in release builds, so you can sti= ll run the debugger on them when you attach to the process of the python in= terpreter EXE. And especially be sure to use the RELEASE runtime library f= lag (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 tem= plates/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 d= oesn't adhere to template standards correctly and you often end up with mul= tiply-defined functions if you don't use that macro. If I remember correct= ly. (It's been a while.) That and you may be picking up variable length arrays out of your teeth, r= eplacing chunks of code with the use of new and delete operators. No one t= ests for Microsoft and the MS compiler is way behind in adhering to C/C++ s= tandards, 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