473,379 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 1756
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David McNab | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm working on a python plugin for someone else's code written in C. On the whole, I'm successfully embedding the python interpreter,...
4
by: Anand K Rayudu | last post by:
Hi All, I have one problem with embedding python into my application. on HP-UX11 i created my application with linking libPython2.3.a And with my product i supply all extension dlls and with...
1
by: tom fogal | last post by:
Hi all, I can't seem to find out how to get a python script to run from a C (well, C++...) program. In particular, I'm confused about how the execution of the example code at...
3
by: brobigi | last post by:
well I manage to figure it out myself. I'm using Bloodshed Dev-cpp Here's the code: #include "python.h" #include <stdio.h> int main(int argc, char* argv) { double answer = 0;
3
by: Jim Hill | last post by:
Well, I've found about a hundred thousand web pages where people have had the same problem I have but nary a page with a solution that works for me. I want to do a simple embed, so I've followed...
0
by: Lane Brooks | last post by:
I am embedding python into a linux shared library (let's call it libembedpy.so). The main application loads this shared library dynamically using libdl and is not linked against libembedpy.so ...
4
by: David Abrahams | last post by:
I'm seeing highly surprising (and different!) behaviors of PyImport_ImportModule on Linux and Windows when used in a program with python embedding. On Linux, when attempting to import a module...
4
by: DavidM | last post by:
Hi all, I'm embedding python in a C prog which is built as a linux shared lib. The prog is linked against libpython, and on startup, it calls Py_Initialize(). The prog imports a pure-python...
1
by: kaush | last post by:
Hi All, I have a simple python script saved to "test.py" as import os import base64 def Testfunction(): print "Hello World" return
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.