Cannot import the Hello World module of Boost.Python's QuickStart in python
I followed the steps in the QuickStart of Boost.Python here: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.boost.org_doc_libs_1-5F49-5F0_libs_python_doc_tutorial_doc_html_index.html&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=jSyKml46sQcyHEvdXhVDNwoCqN0MBfWgTmJFqTljZKM&m=6Z-RP-Mjs781YKE08gvO6owK6zMqGXD7ZRueaJHfUNo&s=2-beQ7RazSZIfAiaWI9QGvRv_EumlzP0E6iD2Qfmntg&e= . I can successfully compile, link and get the output dll file, but I always got and error: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named hello_ext when trying to import it in python. This is my environment: - Windows 7 Enterprise SP1 64 bit, I am the Administrator and run cmd as Administrator. - Python 2.7.13 64 bit - Visual Studio 2015 (v14.0) Update 3 - In VS2015, the project name is ConsoleApplication1, so the output is ConsoleApplication1.dll. - I built the simple sample code under x64 configuration in VS2015 and I verified with dumpbin that the output ConsoleApplication1.dll is really 64 bit. I tried the following but got the same error: - I added the search path to the ConsoleApplication1.dll into sys.path - I changed the name of ConsoleApplication1.dll to hello_ext.dll The QuickStart says "The resulting DLL is now visible to Python." but that magic does not take place on my machine. Could you please tell me what I had missed or, if I built the DLL properly, how to import it in python command line? Thanks a lot.
I solved the problem myself. This is a link to my answer: https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_44161857_the-2Ddll-2Dcreated-2Dby-2Dboost-2Dpython-2Dcannot-2Dbe-2Dimported-2Dfollowing-2Dboost-2Dpythons-2Dqui_44194094-2344194094&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=jSyKml46sQcyHEvdXhVDNwoCqN0MBfWgTmJFqTljZKM&m=Z6BHCcdSSCk4Tyk1aODuxJJLvF5j7M6QqGMajnzntSs&s=1iKwggA27bECIO0iVuLFA4Zz40g5EQ38MrwLBqKfBjY&e= On Thu, May 25, 2017 at 12:54 AM, Heng Zhou <hzhou3@clemson.edu> wrote:
I followed the steps in the QuickStart of Boost.Python here: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.boost.org_doc_libs_1-5F49-5F0_libs_python_doc_&d=DwIBaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=jSyKml46sQcyHEvdXhVDNwoCqN0MBfWgTmJFqTljZKM&m=Z6BHCcdSSCk4Tyk1aODuxJJLvF5j7M6QqGMajnzntSs&s=B7c9mrc4EPId10XO2UsWu_OZHNf3tA6rtPRvqJ2f_dE&e= tutorial/doc/html/index.html. I can successfully compile, link and get the output dll file, but I always got and error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named hello_ext
when trying to import it in python. This is my environment:
- Windows 7 Enterprise SP1 64 bit, I am the Administrator and run cmd as Administrator. - Python 2.7.13 64 bit - Visual Studio 2015 (v14.0) Update 3 - In VS2015, the project name is ConsoleApplication1, so the output is ConsoleApplication1.dll. - I built the simple sample code under x64 configuration in VS2015 and I verified with dumpbin that the output ConsoleApplication1.dll is really 64 bit.
I tried the following but got the same error: - I added the search path to the ConsoleApplication1.dll into sys.path - I changed the name of ConsoleApplication1.dll to hello_ext.dll
The QuickStart says "The resulting DLL is now visible to Python." but that magic does not take place on my machine. Could you please tell me what I had missed or, if I built the DLL properly, how to import it in python command line? Thanks a lot.
participants (1)
-
Heng Zhou