Jython Script works in Eclipse, but not in Command Prompt

Asked by aidma

My Jython script runs properly when run in eclipse, but fails when run via command line.

I have Sikuli 1.1.0 set up in Eclipse per the instructions found here: https://github.com/RaiMan/SikuliX-2014/wiki/Usage-in-Java-programming. My Jython script starts with:

import org.sikuli.basics.SikulixForJython
from sikuli import *

I've also added C:\SikuliX1.1\sikulixapi.jar to the (pydev) PYTHONPATH. And, as expected, my script works when run.

But, if I navigate to my project in command line and run with the command:

jython -Dpython.path=C:\SikuliX1.1\sikulixapi.jar __init__.py

I get the error:

[error] SikuliXforJython: package: sikuli/__init__.py not found: Sikuli might not work
Traceback (most recent call last):
  File "__init__.py", line 4, in <module>
    from sikuli import *
ImportError: No module named sikuli

Any idea what I'm doing wrong?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

jython -Dpython.path=C:\SikuliX1.1\sikulixapi.jar __init__.py

-Dpython.path=C:\SikuliX1.1\sikulixapi.jar
... is not needed, since this is added automatically at runtime by
import org.sikuli.basics.SikulixForJython

but as mentioned in the wiki:
sikulixapi.jar must be on the Java classpath.
The easiest way when running from commandline (before issuing the python command):
set CLASSPATH=C:\SikuliX1.1\sikulixapi.jar;%CLASSPATH%

Revision history for this message
aidma (aidan-mahler13) said :
#2

I thought that the PYTHONPATH and CLASSPATH were the same thing when using Jython. You have corrected my error.

I've added sikulixapi.jar to a CLASSPATH environment variable and now the imports work as expected. Thanks for the help!

Revision history for this message
aidma (aidan-mahler13) said :
#3

Thanks RaiMan, that solved my question.