Cannot use Winpdb (or PyDev) to trace embedded Python script in MSVC++ application - ImportError: No module named _socket

Nir nir1408 at gmail.com
Fri Jun 6 10:13:28 CEST 2008


You seem to be having a problem with the import path of the embedded
interpreter. I suppose the embedded interpreter includes some modules
in a particular folder and _socket is not one of them. For the sake of
debugging try adding the c:\python25\lib path to the sys.path variable
of the interpreter before attempting to import rpdb2.

Does this work?

Nir


On Jun 5, 2:52 pm, Chris8B... at gmail.com wrote:
> I am embedding Python in a MSVC++ (2005) application. The application
> creates some environment and then launches a Python script that will
> call some functions exported from the MSVC++ application.
>
> I want to be able to debug the Python script by using a debug server,
> likeWinpdb(winpdb.org).
>
> I use ActivePython 2.5.2.2, Microsoft Visual Studio 2005, andWinpdb
> 1.3.8.
>
> When I launch a script like "e:>python test.py" everything is O'K and
> I can useWinpdbto trace/debug.
>
> When I run the same script from the MSVC++ application, there is
> always a complain "ImportError: No module named _socket".
>
> Here is the basic test script I use:
>
>
>
> def Process( something ):
>     print "\n\nStarted debugging\n=================\n"
>     #pydevd.settrace()
>     import rpdb2; rpdb2.start_embedded_debugger("1")
>     print "\n\nStopped debugging\n=================\n"
>
> if __name__ == '__main__':
>     Process( "test" )
> <<<
>
> In the MSVC++ application I tried many approaches, as suggested by
> many people, and all of them work to launch the script, but none of
> them works withWinpdb(or PyDev for Eclipse - same problem). Just for
> completeness - here is one:
>
>
>
>   PyRun_SimpleString("import sys");
>   PyRun_SimpleString("import os");
>   PyRun_SimpleString( "fullpath = os.path.abspath(\"E:/Test.py\")" );
>   PyRun_SimpleString( "g = globals().copy()" );
>   PyRun_SimpleString( "g['__file__'] = fullpath");
>   PyRun_SimpleString( "execfile(fullpath, g) ");
> <<<
>
> If I use pdb (import pdb + pdb.runcall(something) ) everything works
> fine, but I need the performance and convinience ofWinpdb.
>
> What am I doing wrong?
>
> Your help is highly appreciated!
>
> Best regards,
> Chris




More information about the Python-list mailing list