error

G

Guest

Hi,

Today is my first day of working on python. I want to execute python
script through C++ program. I found one very good article with example
at http://docs.python.org/ext/pure-embedding.html.
I followed the procedure as given, the code is compiled but while
running it is giving error like:
ImportError: No module named multiply
Failed to load "multiply"

Here are the steps I followed, please suggest where I am wrong and how
can I remove the above error.

Step 1: Copied the given C program into a file called test.cpp (using vi
editor)
Step 2: Compiled it using : g++ test.cpp /usr/lib/libpython2.4.so
(created a.out)
Step 3: Wrote the given script of multipication in a file named as
multiply (using vi editor)
Step 4: But while running the program using : ./a.out multiply
multiply 3 2
Getting this error: ImportError: No
module named multiply
Failed to
load "multiply"

Please help me out.

Thanks & Regards,
Prashant Burghate
Project Engineer,
Embedded Systems,
Wipro Technologies, Pune.
Tel: +91-20-22933700 Extn: 51570
Mob. # 9850428252
Email: (e-mail address removed)


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com
 
R

Rob Wolfe

Hi, [...]
Step 3: Wrote the given script of multipication in a file named as
multiply (using vi editor)

The name of module should be multiply.py

HTH,
Rob
 
J

John Machin

Hi,

Today is my first day of working on python. I want to execute python
script through C++ program. I found one very good article with example
at http://docs.python.org/ext/pure-embedding.html.
I followed the procedure as given, the code is compiled but while
running it is giving error like:
ImportError: No module named multiply
Failed to load "multiply"

Here are the steps I followed, please suggest where I am wrong and how
can I remove the above error.

Step 1: Copied the given C program into a file called test.cpp (using vi
editor)
Step 2: Compiled it using : g++ test.cpp /usr/lib/libpython2.4.so
(created a.out)
Step 3: Wrote the given script of multipication in a file named as
multiply (using vi editor)

Try naming your source file multiply.py but continue to use the module
name (multiply) in the command line. [Note: you could have a binary
extension module called multiply in a binary file called multiply.so]

I guess the author of that manual section didn't contemplate somebody
on their first day with Python doing some embedding :)

HTH,
John
 
J

John Machin

Rob said:
Hi, [...]
Step 3: Wrote the given script of multipication in a file named as
multiply (using vi editor)

The name of module should be multiply.py

module != source_file
module don't have no ferschlugginer dots in its name
 
R

Rob Wolfe

John said:
Rob said:
Hi, [...]
Step 3: Wrote the given script of multipication in a file named as
multiply (using vi editor)

The name of module should be multiply.py

module != source_file
module don't have no ferschlugginer dots in its name

Ooops... sorry.
I meant name of python source file, of course.

Regards,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Exception Handling 1
variadic function 27
Problem with proxies 3
Python IDLE 2
soap library for python-3.x 0
NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py 0
ERROR 0
Keyword passing to superclass written in C 0

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top