472,988 Members | 3,399 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

weird embedding problem

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 script. The script starts up ok, but when
it imports the 'math' module, the import fails with:

Traceback (most recent call last):
File "/home/david/work/video/myprogs/dvedit/test/frei0rfx1.py", line 10, in <module>
import math
ImportError: /usr/lib/python2.5/lib-dynload/math.so: undefined symbol: PyExc_ValueError
Failed to import math

Any ideas of how to work around this?

Please note - the program I'm writing *must* be built as a shared lib, so
the usual practice of 'extend, don't embed' is just not an option here.

Thoughts?

Cheers
D
Dec 7 '07 #1
4 2625
On Dec 7, 2:01 pm, DavidM <nos...@nowhere.comwrote:
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 script. The script starts up ok, but when
it imports the 'math' module, the import fails with:

Traceback (most recent call last):
File "/home/david/work/video/myprogs/dvedit/test/frei0rfx1.py", line 10, in <module>
import math
ImportError: /usr/lib/python2.5/lib-dynload/math.so: undefined symbol: PyExc_ValueError
Failed to import math

Any ideas of how to work around this?

Please note - the program I'm writing *must* be built as a shared lib, so
the usual practice of 'extend, don't embed' is just not an option here.

Thoughts?

Cheers
D
the math module above is failing to load because of: "undefined
symbol: PyExc_ValueError"
You may have to import some other module before loading math.
Try doing nm on libraries in /usr/lib/python2.5/lib-dynload & see
which one has this symbol (a function) in defined state ("T").

Also, verify if your script works fine out of the C program - may be
at python prompt.
Dec 7 '07 #2
On Dec 7, 5:01 pm, DavidM <nos...@nowhere.comwrote:
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 script. The script starts up ok, but when
it imports the 'math' module, the import fails with:

Traceback (most recent call last):
File "/home/david/work/video/myprogs/dvedit/test/frei0rfx1.py", line 10, in <module>
import math
ImportError: /usr/lib/python2.5/lib-dynload/math.so: undefined symbol: PyExc_ValueError
Failed to import math

Any ideas of how to work around this?

Please note - the program I'm writing *must* be built as a shared lib, so
the usual practice of 'extend, don't embed' is just not an option here.

Thoughts?
Are you actually linking your C program against the Python library?

Graham

Dec 7 '07 #3
On Fri, 07 Dec 2007 00:53:15 -0800, Graham Dumpleton wrote:
Are you actually linking your C program against the Python library?
Yes. Refer OP:
>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().
Dec 7 '07 #4
On Dec 7, 11:44 pm, DavidM <nos...@nowhere.comwrote:
On Fri, 07 Dec 2007 00:53:15 -0800, Graham Dumpleton wrote:
Are you actually linking your C program against the Python library?

Yes. Refer OP:
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().
What was the compiler link line you used for your program/shared
library then?

Have you confirmed using 'ldd' command that your program/shared
library do actually link against libpython?

Your original description is confusing. You say your program is built
as a shared library. Can you properly explain the full process you are
using to build your code and if you are producing a shared library for
your program how then is that shared library being used with an actual
executable? Be specific about where the program main() is located?

Some platforms don't necessarily find symbols from shared library 'A'
linked against a program executable if the main() is actually obtained
from a shared library 'B" linked to the same program and where the
symbols required from 'A' are only used in 'B'. What is required is to
link library 'A' against library 'B'.

Graham
Dec 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
2
by: Roose | last post by:
With some googling I have found these resources: http://docs.python.org/ext/win-dlls.html http://www.python.org/doc/faq/windows.html I have a large Win32/MFC/C/C++ application that has an...
7
by: Ryan Park | last post by:
Hi, //SITUATION I got a panel control that hold a certain position on a form. Every controls or UIs are on this panel. At certain situation, I called dispose() method of this panel control...
2
by: Lyn | last post by:
I am trying to embed a picture into a Bound Object Frame (Me!Photograph) with the following code which is based on MS article http://support.microsoft.com/?id=158941: strPathname =...
13
by: Krzysztof Bartosiewicz | last post by:
Hi! I have a problem with an access database. The database which I designed and made using MS access works perfectly OK on my computer however it is not working at all on computers for which it...
6
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python...
6
by: mistabean | last post by:
Hello, first of all, I am a programming newbie, especially in python... Onwards to the problem, I have been having difficulty embedding a python module into my C/C++ program. (just a test...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.