Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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; 'importing': 0.04; 'interpreter': 0.04; 'compiler': 0.05; 'debug': 0.05; 'pop': 0.05; '(especially': 0.07; 'c++,': 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; 'to:addr:comp.lang.python': 0.09; 'windows,': 0.09; 'wrong,': 0.09; 'cc:addr:python-list': 0.10; 'template': 0.11; 'subject:python': 0.11; 'library': 0.15; 'weird': 0.15; "(it's": 0.16; '24,': 0.16; 'ah,': 0.16; 'boost.': 0.16; 'compiler,': 0.16; 'enough.': 0.16; 'googled': 0.16; 'hurts': 0.16; 'liu': 0.16; 'macro': 0.16; 'md,': 0.16; 'naive': 0.16; 'numpy': 0.16; 'operators.': 0.16; 'reason.': 0.16; 'sorts': 0.16; 'subject:File': 0.16; 'subject:embed': 0.16; 'subject:import': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'replacing': 0.17; 'subject:project': 0.17; 'tests': 0.18; 'module': 0.19; 'variable': 0.20; 'bit': 0.21; 'import': 0.21; '(usually': 0.22; 'flags': 0.22; 'init': 0.22; 'cc:2**0': 0.23; "i've": 0.23; 'seems': 0.23; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(such': 0.27; 'c++': 0.27; 'dll': 0.27; 'found.': 0.27; 'propose': 0.27; "doesn't": 0.28; 'run': 0.28; 'arrays': 0.29; 'embed': 0.29; 'initialized': 0.29; 'lot.': 0.29; 'assistance,': 0.30; 'attach': 0.30; 'standards': 0.30; 'thursday,': 0.30; 'function': 0.30; 'code': 0.31; 'file': 0.32; 'anybody': 0.32; 'suggestion': 0.32; 'could': 0.32; 'builds': 0.33; 'correctly.': 0.33; 'hopefully': 0.33; 'picking': 0.33; 'traditional': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'project': 0.34; 'wrong': 0.34; 'thanks': 0.34; 'problem,': 0.35; 'especially': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'add': 0.36; 'really': 0.36; 'but': 0.36; 'alone': 0.36; "wasn't": 0.36; 'should': 0.36; 'thank': 0.36; 'correctly': 0.37; 'two': 0.37; 'being': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'behind': 0.38; 'some': 0.38; 'things': 0.38; 'nothing': 0.38; 'sure': 0.38; 'delete': 0.38; 'instead': 0.39; 'release': 0.39; 'build': 0.39; 'called': 0.39; 'little': 0.39; 'help': 0.40; 'end': 0.40; 'your': 0.60; 'days': 0.60; 'solve': 0.62; 'between': 0.63; 'times': 0.63; 'information': 0.63; 'more': 0.63; 'here': 0.65; 'results': 0.65; 'dear': 0.66; 'hours': 0.66; 'finally': 0.66; 'mail.': 0.69; 'receive': 0.71; 'sounds': 0.71; 'saw': 0.75; '2013': 0.84; 'adhere': 0.84; 'daunting.': 0.84; 'depended': 0.84; 'perfect!': 0.84; 'standards,': 0.84 X-Received: by 10.50.163.101 with SMTP id yh5mr132852igb.13.1358995430310; Wed, 23 Jan 2013 18:43:50 -0800 (PST) Newsgroups: comp.lang.python Date: Wed, 23 Jan 2013 18:43:50 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=183.221.13.237; posting-account=C5ZW1goAAABBiDY20ieZObmqNJVCIaGw References: <552da0d2-e744-4ce2-8204-14a7274515de@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 183.221.13.237 MIME-Version: 1.0 Subject: Re: Failed to import a "pyd: File When python intepreter embed in C++ project From: Junze Liu To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "python-list@python.org" 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: , Message-ID: Lines: 86 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358995439 news.xs4all.nl 6843 [2001:888:2000:d::a6]:45801 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37532 On Thursday, January 24, 2013 12:28:58 AM UTC+8, Leonard, Arah wrote: > > I create a pyd File named "testPyd" with boostPython,and then I import = the testPyd module into "test.py", it works perfect! >=20 > > But when I embeded the python interpreter into my C++ project and run t= he "test.py", it comes out a "ImportErr: no module named testPyd". >=20 > > It has confused me for two days and I googled for long time,but I can't= find the answer! >=20 > > Anybody here can help me ? >=20 > > Thank you! >=20 > >=20 >=20 >=20 >=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= of weird things can happen (especially on a MS compiler, because no one te= sts 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 n= ame or that the PYD couldn't be found. Just that somewhere, at some time d= uring import, it failed to fully load. >=20 >=20 >=20 > In my use a lot of times it was either that a DLL that module depended o= n wasn't in the path, or my favorite kicker, that some compile/link flags b= etween the PYD and the Python interpreter don't match well enough. (Usuall= y from mixing debug and release builds together.) >=20 >=20 >=20 > From what I've seen anyway, the Python interpreter really doesn't like b= eing built in a traditional debug mode, so I always do a release build of i= t. It's a little inconvenient, but in the linker flags you can still set y= our PYDs to generate debug information even in release builds, so you can s= till 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). >=20 >=20 >=20 > That's as much as I know anyway. Though depending, if you add any new t= emplates/libraries into Boost (such as for NumPy ndarray), you also may nee= d 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 m= ultiply-defined functions if you don't use that macro. If I remember corre= ctly. (It's been a while.) >=20 >=20 >=20 > 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. >=20 >=20 >=20 > Hopefully something in all of this helped. Boost can be ... daunting. = I get it, in theory. But in practice it often hurts my head. ;) >=20 >=20 >=20 > Sincerely, >=20 > Arah Leonard Dear Lenoard, Thanks for your hearty assistance, and it finally works.I just change m= y RELEASE Run Time Library flag to MD, then the results come out. Before I receive your mail, I googled for kinds of solutions and tried = to solve this problem, but none of them works.Yesterday, someones said that= the python module in *pyd Files* should be initialized before they can be = embed into C++, and a function named init should be called befo= re importing the module, I was confused with this for a couple of hours unt= il I saw your mail. I am new to boost.python.If I propose any questions that seems naive to = you the other days, any suggestion from you would be more than welcome! =20 Thanks again for your help to make me out of my wrong way! Sincerely, George Liu