[Tutor] FW: Embedding Python

BELSEY, Dylan dylan.belsey@baesystems.com
Tue, 30 Jul 2002 13:52:02 +0930


Hi Tutor list,
	I posted the below mail last week and haven't seen any replies on
the topic so I am not sure if it got through or if the questions were out of
the scope of this list.  If it is out of scope, any suggestions to what list
would be more appropriate.
	Further to the information provided, I compiled the code in
"Release" mode and still obtained the same error.  When I refer to error I
mean the 'import site' failure message.  I would appreciate any help on
this.
	Thanks,
		Dylan


> -----Original Message-----
> From:	BELSEY, Dylan 
> Sent:	Wednesday, 24 July 2002 15:51
> To:	tutor@python.org
> Subject:	Embedding Python
> 
> Hi,
> 	I am attempting to try and get the embedding of Python running on my
> system (WinNT). I am using VC++ and I copied the code from "5.1 Very High
> Level Embedding" within "Extending and Embedding the Python Interpreter"
> from the Python docs.  I have also installed the latest release of Python,
> version 2.3a0.  The code from the documentation is pasted below:
> 
> #include <Python.h>
> 
> int
> main(int argc, char *argv[])
> {
>   Py_Initialize();
>   PyRun_SimpleString("from time import time,ctime\n"
>                      "print 'Today is',ctime(time())\n");
>   Py_Finalize();
>   return 0;
> }
> 
> 	It compiles OK but when I go to run it I get the following error:
> 
> 'import site' failed; use -v for traceback
> Today is Wed Jul 24 15:39:04 2002
> Press any key to continue
> 
> 	Any ideas why this error is occurring.  Has anyone seen this error
> and if so why is it occurring?  The code is compiled in debug mode so
> maybe the error is an artefact of that??  I have noticed that when I put
> the produced executable in the directory where python.exe lives I don't
> get the error.  Unfortunately I don't know enough about the guts of Python
> to follow this discovery through.
> 	Any help would be appreciated.
> 		Dylan