471,353 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

C Embedding problem, ImportError

I'm trying to run some python scripts from a proggy of mine. Most of the
time it works great, but I seem to be having problems with some
modules. Here's what I get when I try importing math (applies to all
..../lib-dynload/ modules, I guess):

ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined
symbol: PyExc_OverflowError

Executing the same script from command-line works ok. What gives?
I'm using python 2.3.2, and the file using the python/c is compiled
invoking:

gcc -o libabc.lib -shared -fpic lpython2.3 -lm abc.c

Thanks,

- Tero

Jul 18 '05 #1
2 1690
Tero Pihlajakoski wrote:
I'm trying to run some python scripts from a proggy of mine. Most of the
time it works great, but I seem to be having problems with some
modules. Here's what I get when I try importing math (applies to all
.../lib-dynload/ modules, I guess):

ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined
symbol: PyExc_OverflowError

Executing the same script from command-line works ok. What gives?
I'm using python 2.3.2, and the file using the python/c is compiled
invoking:

gcc -o libabc.lib -shared -fpic lpython2.3 -lm abc.c


I keep having this issue too, but am far from a Linux guru. I *think*
last time I solved it, it required an explicit dlopen() with RTLD_GLOBAL
for libpythonxx.so. This was required to map the symbols globally, so
other extensions could use it (even though the main program itself does
not need the dlopen().

If you find a better answer, please let me know :)

Mark.

Jul 18 '05 #2

hi Tero,

I also faced similar kind of problem on HP & IBM workstations.
This is how i solved.

run python outside & do following.
It gives out the link options required for that platform, just
re-compile your application with those options.

more information you can find out in python documentation chapter
5.6 Linking Requirements

in my downloaded documentation it is at ~/python-docs-2.3/ext/link-reqs.html
import distutils.sysconfig
distutils.sysconfig.get_config_var('LINKFORSHARED' )
'-Xlinker -export-dynamic'

Hope this helps!! :-)

Anand

Tero Pihlajakoski wrote:
I'm trying to run some python scripts from a proggy of mine. Most of the
time it works great, but I seem to be having problems with some
modules. Here's what I get when I try importing math (applies to all
.../lib-dynload/ modules, I guess):

ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined
symbol: PyExc_OverflowError

Executing the same script from command-line works ok. What gives?
I'm using python 2.3.2, and the file using the python/c is compiled
invoking:

gcc -o libabc.lib -shared -fpic lpython2.3 -lm abc.c

Thanks,

- Tero

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by David McNab | last post: by
4 posts views Thread by Anand K Rayudu | last post: by
1 post views Thread by tom fogal | last post: by
reply views Thread by Lane Brooks | last post: by
4 posts views Thread by David Abrahams | last post: by
4 posts views Thread by DavidM | last post: by
1 post views Thread by kaush | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.