ImportError in embedded Python Interpreter

Gabriel Genellina gagsl-py2 at
Fri Jan 30 01:23:35 CET 2009

En Thu, 29 Jan 2009 17:07:01 -0200, <googler.1.webmaster at>  

> i have a problem. I compiled Python and the socket module so I got
> this structure. (all on windows)
> C:\test\dll_files\python25.dll
> C:\test\my_app
> C:\test\dll_files\DLLs\
> C:\test\dll_files\python.exe
> If I run python.exe I get the console and I can call "import socket"
> which
> succeeds. I wrote a small console app which is stored in C:\test\ and
> embeddeds the python interpreter. I set the environment variable PATH
> so the python25.dll can be load.

The easiest way is to mirror the directory structure of a standard Python  
install. Python looks for Lib/ and, once found, derives all the other  
paths from here. See PC/getpathp.c in the source distribution.

You have these alternatives:

- put a lib\* containing at least below the directory containing  
your main executable.

- set a PYTHONHOME variable

- call Py_SetProgramName

- completely replace getpathp.c with your own functions

Gabriel Genellina

More information about the Python-list mailing list