Zachary Turner
2014-10-03 17:07:00 UTC
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.
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.
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?
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?
Thanks
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.
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?
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?
Thanks