Hi All,
I have a simple python script saved to "test.py" as
import os
import base64
def Testfunction():
print "Hello World"
return
Testfunction()
I am trying to invoke this from a C program as follows
int main(int argc, char* argv[])
{
Py_Initialize();
PyObject* main_module = PyImport_AddModule("__main__");
PyObject* main_dict = PyModule_GetDict(main_module);
FILE* file_1 = fopen(TestFile, "r");
PyRun_AnyFile(file_1, TestFile);
Py_Finalize();
return 0;
}
This fails with the error
Traceback (most recent call last):
File "/home/kaushik/shadowFs/test.py", line 4, in <module>
import base64
File "/usr/local/lib/python2.5/base64.py", line 9, in <module>
import struct
File "/usr/local/lib/python2.5/struct.py", line 30, in <module>
from _struct import Struct, error
ImportError: /usr/local/lib/python2.5/lib-dynload/_struct.so:
undefined symbol: PyExc_TypeError
I am able to run test.py successfully from the shell.
What am i missing in importing the base64 library?
Thanks,
Kaushik 1 3268
On Mar 15, 2:10 am, kaush <kaushikba...@gmail.comwrote:
Hi All,
I have a simple python script saved to "test.py" as
import os
import base64
def Testfunction():
print "Hello World"
return
Testfunction()
I am trying to invoke this from a C program as follows
int main(int argc, char* argv[])
{
Py_Initialize();
PyObject* main_module = PyImport_AddModule("__main__");
PyObject* main_dict = PyModule_GetDict(main_module);
FILE* file_1 = fopen(TestFile, "r");
PyRun_AnyFile(file_1, TestFile);
Py_Finalize();
return 0;
}
This fails with the error
Traceback (most recent call last):
File "/home/kaushik/shadowFs/test.py", line 4, in <module>
import base64
File "/usr/local/lib/python2.5/base64.py", line 9, in <module>
import struct
File "/usr/local/lib/python2.5/struct.py", line 30, in <module>
from _struct import Struct, error
ImportError: /usr/local/lib/python2.5/lib-dynload/_struct.so:
undefined symbol: PyExc_TypeError
I am able to run test.py successfully from the shell.
What am i missing in importing the base64 library?
Thanks,
Kaushik
Adding the following link options during compilation solved the
problem "-Xlinker -export-dynamic"
Thanks,
Kaushik This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Carsten Gehling |
last post by:
Figured out myself - I just removed the line with "from url import Url" -it
doesn't seem to be used anywhere ;-)
- Carsten
> -----Oprindelig meddelelse-----
> Fra:...
|
by: M. Lavasani |
last post by:
Hi
I am trying to test Python-2.3.
Any solution for this problem please:
>>>gmake test
case $MAKEFLAGS in \
*-s*)...
|
by: Chris Hodapp |
last post by:
I have seen messages posted about this before, and there is a clear
reference to it in the manual, but I have been unable to find a
solution.
I'm on Slackware 9.1, kernel 2.6.0-test11, using...
|
by: Tero Pihlajakoski |
last post by:
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...
|
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...
| |
by: Adam Blinkinsop |
last post by:
I'm writing a set of modules to monitor remote system services, and I'm
having a problem running my test scripts. When I pass the scripts into
python, like so:
--
$ PYTHONPATH="${TARGET_DIR}"...
|
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...
|
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...
|
by: manasonnet |
last post by:
ava.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |