Embedded Python (in C) example.

Alex Martelli aleax at aleax.it
Wed Feb 5 09:05:28 EST 2003


jbi130 at yahoo.com wrote:
   ...
> $ ./call multiply 2 2
> ImportError: No module named multiply
> Failed to load "multiply"

I see two problem with this invocation (which IS exactly what's given
in the example - so, there are bugs in the docs!):

-- the call executable requires different parameters,
   as the executable itself says when called w/o arguments:
       Usage: call pythonfile funcname [args]

-- the module loaded must be on the python path

So, for example, the following invocation does work fine:

[alex at lancelot ball]$ PYTHONPATH=. ./call multiply multiply 3 2
Thy shall add 3 times 2
Result of call: 6

> Is there something missing from the example to make it work?

Yep, two things (from the invocation -- the C code is fine).

> Also, my hope is to embed Python in an application in such away that
> it can be be used on systems without a Python environment installed.
> I don't think there should be any issues with this, but would like to
> be sure.

As long as you make available (on python's path, as determined
by your embedding application; and possibly on the path that is
searched to load dynamically-loaded libraries on your system,
depending on your platform) every module and package that gets
imported, and every DLL (or .so &c) needed for the run, I do not
think there should be any other problem.


Alex





More information about the Python-list mailing list