This project has moved and is read-only. For the latest updates, please go here.

Can't get "Start Debugging" to work with custom built interpreter

Nov 28, 2013 at 7:51 AM
We use a custom built Python interpreter in our project and I have created a new Python environment for it. Ctrl + F5 "Start without debugging" works fine but I can't get F5 "Start Debugging" to work. The following error is displayed in the console window:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio
ns\Microsoft\Python Tools for Visual Studio\2.0\", li
ne 21, in <module>
    import visualstudio_py_debugger
  File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio
ns\Microsoft\Python Tools for Visual Studio\2.0\", li
ne 17, in <module>
    import ctypes
  File "F:\bin\lib\ctypes\", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes
The Python interpreter and all its dependencies are located in the F:\bin directory and F:\bin\DLLs does contain a _ctypes.pyd (F:\bin contains a complete custom built version of Python 3.2). Maybe worth mentioning that the F: drive is a SUBST:ed directory.

My custom Python Environment has these settings:

Path: F:\bin\python_d.exe
Library Path: F:\bin\Lib
Path Environment Variable: F:\bin\DLLs

And these project settings:

Working Directory: F:\bin
Debug - Search Paths: F:\bin\out;F:\bin\DLLs;F:\bin\Lib

Where F:\bin\out contains our own Python modules.

Both the stable release and the latest development build of Python Tools for Visual Studio 2013 give the same error.

I did a couple of searches on the web for similar problems and found this report for ActiveState Python 2.6 which sounds similar and in which the the user says removing the APPDATA environment variable fixed it:

I have not tried this and would prefer not to.

Any ideas? Have I missed a setting somewhere or is it a bug?
Nov 28, 2013 at 8:06 AM
Judging by python_d.exe, you're using a debug build of Python. This requires that the binary modules are also built in debug configuration, which, among other things, means that their names must be similarly suffixed with _d - so it's looking for _ctypes_d.pyd and not finding it. That should have been produced as part of your Python build.
Nov 28, 2013 at 8:14 AM
I can see other _d.pyd files but _ctypes_d.pyd does seem to be missing. I'll try to build a new debug version of the Python interpreter.

Nov 28, 2013 at 9:21 AM
Ok, I have built the missing _d.pyd files but it still does not work.

The output window keeps printing the following error and then exits:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Micro
soft\Python Tools for Visual Studio\2.0\ Resour
ceWarning: unclosed <socket.socket object, fd=420, family=2, type=1, proto=0>
  conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
I am currently using the development build, not the stable release.