What parts of C:\Python25 are important?

Fredrik Lundh fredrik at pythonware.com
Tue Aug 19 19:20:53 CEST 2008

Robert Dailey wrote:

> I've currently embedded the python interpreter into a C++ application of 
> mine. I want to bundle the python core library with my application so 
> the user does not have to install python to use my application. What 
> files do I need to copy over? Help is appreciated, thank you.

off the top of my head:

- python25.dll (from \windows\system32, usually)

- any extension PYD:s and DLL:s you're using (from \python25\DLLs)

- either the contents of the standard library (\python25\Lib)
   in PY and/or PYC form, or a zipped archive that contains all
   the PYC files in there (zipped relative to \python25\Lib).

- (optional) MSVCR71.dll (but that's usually already installed, afaik)

you also need to make sure that your application sets an appropriate 
path before it starts importing things, either by munging sys.path via 
embedded Python code, or via a call to Py_SetPythonHome.  the comment 
block at the top of


explains how the default path is created on Windows.

in some cases, it helps to tell Python not to import the "site" module 
by itself, and then import site when you've set everything up.  to do 
that, insert "-S" in the argv buffer before calling PySys_SetArgv.  you 
may also want to remove any PYTHON-related environment variables from 
the local environment, before initializing Python.


More information about the Python-list mailing list