Import error from within python module

Asked by Neil

I'm trying to use a python module within Sikuli IDE. I've added the site-packages path to sites.txt, as per the documentation. So the module is found.
But when the module tries to import other python modules (from the standard library), there's an error. I tried importing the dependent modules manually, and it works for BytesIO in the IO library, but not for zip_longest in the itertools library.

import io # mutagen requires the BytesIO module in the IO Library
from io import * # saw this in a previous answer from Raiman on importing modules
import mutagen # no error - the package is found
import itertools
from itertools import * # trying to pre-import zip_longest before the next line
from mutagen.wave import WAVE # this is where the error occurs

[error] script [ audio ] stopped with error in line 6
[error] ImportError ( cannot import name zip_longest )
[error] --- Traceback --- error source first
line: module ( function ) statement
11: _tags ( <module> ) from itertools import zip_longest
19: _file ( <module> ) from ._tags import ID3Tags, ID3Header, ID3SaveConfig
32: __init__ ( <module> ) from ._file import ID3, ID3FileType, delete, ID3v1SaveOptions
16: wave ( <module> ) from mutagen.id3 import ID3
6: main ( <module> ) from mutagen.wave import WAVE
[error] --- Traceback --- end --------------

Note, I've tried the code in the Python environment (command prompt) and it works. Do I need to point Sikuli to the python standard library?

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

Python modules can only be used in SX if they are made in Python language only and do not contain/depend on native code/libraries.

So they might be found, but not are useable.

Pointing to the Python standard lib does not make sense, since this is available as the Jython version in the SX environment.

Additionally be aware: Jython is on language level 2.5

Revision history for this message
Neil (morrissn) said :
#2

Thanks RaiMan, that solved my question.