On Fri, Oct 3, 2014 at 12:07 PM, Zachary Turner <ztur...@google.com> wrote: > Hi, > > I'm trying to embed python 2.7 in a Win32 application and I'm running into a > host of problems. > > Originally, my problem was that when compiling a debug version of my > application and linking against the python27.lib that I installed via the > packaged installer, I would just get strange behavior and memory corruption > and random crashes. I finally determined that this was basically just > impossible, and if I want to use embedded python in a debug version of my > application, I need to build my own debug version of python. > > This leads me to my first question: Was my original determination accurate? > I think all of my problems would be solved automatically if I could just > embed release python in a debug version of my application.
I believe you're correct. It is a somewhat unfortunate limitation; it's on my radar to see if it can be relaxed, but I haven't had time to look into it very closely yet. > Fast forward a bit. I now have a custom debug build of python. My debug > build of application links against it, and release build links against > release python. So far so good, until I try to run "import ctypes". Then I > get this: > > Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>>> import ctypes > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "d:\python_src\Python-2.7.8\Lib\ctypes\__init__.py", line 10, in > <module> > from _ctypes import Union, Structure, Array > ImportError: No module named _ctypes > > Anybody have any idea what is going on here or how I might diagnose this? > It's obviously located the ctypes module that came with the source > distribution, so what error could it be running into? What do you get if you do 'import sys; print sys.path'? Is the directory that holds _ctypes.pyd included in sys.path? > For reference, the way I've built this is to download Python 2.7 source > distribution, open up the solution in Visual Studio, and build it, then have > my application link against the binaries that are put into the build's > output directories. Is there a different way? That ought to be about right. -- Zach _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32