By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,543 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,543 IT Pros & Developers. It's quick & easy.

Jython Problem

P: 1

I'm trying to execute a Python script from a Java class using Jython. I'm running into the following error:

Exception in thread "main" Traceback (innermost last):
File "<string>", line 1, in ?
File "C:\PorkyPortal\diagram-generator\.\", line 13, in ?
ImportError: no module named PIL

I've tried to solve the problem with these instructions:

Here is the code I'm using:

PythonInterpreter interp = new PythonInterpreter();

Properties props = new Properties();
props.setProperty("python.path", "C:\\Python24\\Lib; C:\\Python24\\Lib\\site-packages\\PIL; C:\\Python24\\Scripts\\");
PythonInterpreter.initialize(System.getProperties( ), props, new String[] {""});

interp.exec("import tilemaker");
interp.exec("import Image");
interp.exec("import glob");
interp.exec("img = tilemaker.prepare(AlternateExample.png, FFFFFF, chatty = False);");
interp.exec("img2 = tilemaker.subdivide(img, level = 0, quadrant=(0, 0), size=(128, 128),filename=outputName + '-%d-%d-%d.jpg', quality = None, chatty = False)");

Any suggestions?
Jul 12 '06 #1
Share this Question
Share on Google+
1 Reply

P: 12
I think it's a bad idea to use Java -> Jython -> CPython.
Use Java native image manipulation libraries, or pure Python (aka CPython) + PIL.
Jul 20 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.