On 16/11/2013 2:55 AM,
fira...@gmail.com wrote:
> Finally I run emcc on the generated C file:
>
> emcc test.c
libpython2.7.so -IInclude -I.
>
>
> When I run the generated javascript in my browser I receive the
> following errors:
>
> preload time: 2 ms a.out.js:99
> Could not find platform independent libraries <prefix> a.out.js:99
> Could not find platform dependent libraries <exec_prefix> a.out.js:99
> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] a.out.js:99
> ImportError: No module named site a.out.js:99
> exit(1) called a.out.js:96
>
>
> This basically tells me python was unable to load site.py.
Python can be quite picky about the layout of files it expects to find
on disk. There are two things you could try here.
The first is to disable the loading of site.py. For a command-line
python this is done with the "-S" command-line option, I'm not sure if
that will also work with the embedding thing you're doing here.
However, I suspect it will still try to load other modules at startup
e.g the "os" module.
The second option is to embed the entire python stdlib into your
javascript file, at the same location as it is on your local machine.
For example:
--embed-file /usr/lib/python2.7@usr/lib/python2.7
(I've found this "path@path" syntax necessary to prevent complaints
about embedding files with absolute paths; your mileage may vary)
This will embed a *lot* of stuff, but it should let python find the
files it wants.
If you manage to get it working with the whole stdlib included, then you
can gradually try including fewer and fewer files until you find the
minimal set that it needs. You'll probably wind up with at least:
--embed-file /usr/lib/python2.7/site.py@usr/lib/python2.7/site.py
--embed-file /usr/lib/python2.7/os.py@usr/lib/python2.7/os.py
As suggested in the original error message, you can also use the
PYTHONHOME environment variable to control where python looks for these
files. More details on how to tweak the python startup sequence are
available at:
http://docs.python.org/2/using/cmdline.html
Hope this helps!
Cheers,
Ryan