configparser error in Sikuli 1.0.1

Asked by Marius

I am using Sikuli 1.0.1 and Python 3.3.
I am reading some data from an ini file and use the data later in some python files. These python files contain some functions specific to Sikuli too.
When I want to run the sikuli script I get this error message: "[error] ImportError ( No module named configparser )"

What I know is that for python 3 onwards name of the parser changed from "ConfigParser" to "configparser".
Is it possible that the error is caused by an incompatibility between Pyhon and Sikuli?

Thank you,

Marius

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
RaiMan (raimund-hocke) said :
#1

Generally:
SikuliX scripting depends on the Python language level 2.5 (this year going to level 2.7) and uses the interpreter Jython (a Java implementation of Python).

If you have modules running in Python there are the following restrictions:
- must be for language level 2.5
- cannot contain any native libraries (many Python modules have that and are called C-based). A Python module can be used with Sikuli either when it is ported to the Jython environment or if it is written Python only (good examples are the XLS access module xldd, xlwt, ...)

What you get in turn: you can use any available Java library directly from the scripting level. Many Python libs are mostly API compatible available in the Java World (e.g.Jygments for Pygments).

So check the above prereqs and then at the beginning of your stuff say:
for e in sys.path: print e

to find out where to put your module (really only the python module - usually the folder containing the __init__.py)
Another option:
dir = <abs path to folder containing your module>
if not dir in sys.path: sys.path.append(dir)

things like eggs or install do nothing of value for the Jython/Sikuli environment.

Revision history for this message
Marius (mariusalex09) said :
#2

Hi RaiMan,

Currently your advice helped go further with Sikuli automation. But I still have some questions as something is not clear to me.
So I am writing the automation code in Python. I do not know Java at all.
You said: "cannot contain any native libraries (many Python modules have that and are called C-based). A Python module can be used with Sikuli either when it is ported to the Jython environment or if it is written Python only (good examples are the XLS access module xldd, xlwt, ...) "

1. How do I know which library is native or not?
2. If I have to port a Python module to Jython environment , what do I have to do? Wich steps should I follow?

Thank you very much,

Marius

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

-- 1. How do I know which library is native or not?
You have to either get the information from the package description or even look inside the package, wether it comes with some dll's.
In doubt, you might simply try to import it and see what happens: If the import runs without errors, then it should usually work.

If it is a rather well known package, asking google using
"Jython" "package-name"
should give you some findings.

-- 2. how to use a Python module in the Jython/Sikuli environent
Python modules usually come with installation/egg support. This stuff is not relevant with Jython (does not work).

You have to find the folder inside the module stuff, that contains the module's Python code. This is usually named like the module's name and normally contains the __init__.py (the module initialization code).

Only this folder is needed.

In the Sikuli setup folder (containing the SikuliX jars) make a folder Lib (if it is not yet there).
Simply COPY the identified folder from the Python stuff to this folder Lib (it is on sys.path anyway, as you might check)

an example with the module xlrd is in faq 2208.

Revision history for this message
Marius (mariusalex09) said :
#4

Thank you RaiMan! This information is really important.

Marius