Erros when compiling a CPP program which uses CPython API functions

grbgooglefan ganeshborse at gmail.com
Fri Dec 7 04:38:22 EST 2007


On Dec 7, 5:15 pm, Christian Heimes <li... at cheimes.de> wrote:
> grbgooglefan wrote:
> > I am compiling CPP program which uses CPython API functions from
> > Python 2.5.1 source code
>
> > First I compiled with this commanline, that time I got "pyconfig.h"
> > not found.
>
> On Unix you have to run ./configure and make before you can use a source
> tree. It creates a valid pyconfig.h for you. You may want to use the
> ./configure option --enable-shared.
>
> > So, I added "-I../../PC" to my cmd line to get pyconfig.h, like:
>
> PC/pyconfig.h is for Windows only!
>
> Christian

Thanks for this guidance.
I just now compiled Python 2.5.1 in my home directory. The Linux
machine has Python 2.2.3 already installed.
When I run my above mentioned program which is linked with
libpython2.5.1.a, I get an error as below:

gborse at njl36a-7003:~/prgs/bakup/Python-2.5.1/Demo/embed>./a.out ~/pxm/
parserroot/
'import site' failed; use -v for traceback
['/home/gborse/prgs/bakup/Python-2.5.1/lib/python25.zip', '/home/
gborse/prgs/bakup/Python-2.5.1/lib/python2.5/', '/home/gborse/prgs/
bakup/Python-2.5.1/lib/python2.5/plat-linux2', '/home/gborse/prgs/
bakup/Python-2.5.1/lib/python2.5/lib-tk', '/home/gborse/prgs/bakup/
Python-2.5.1/lib/python2.5/lib-dynload']

I have set the PYTHONHOME to /home/gborse/prgs/bakup/Python-2.5.1 and
PYTHON_LIB to /home/gborse/prgs/bakup/Python-2.5.1/Lib/

But if I run this simialr program compiled with Python2.2.3, it does
not give this error of "import site" failed.
I don't understand how come the "python2.5" is getting appended to
PYTHON_LIB when this "import site" error is coming?

How do we resolve this error?



More information about the Python-list mailing list