[2.0.4] Jython scripting: import Python (pip installed) module like a fake data generator (fake-data)

Asked by Nick

Using manual I added the path to Python site-packages

- make a folder Lib/site-packages in your SikulixAppData folder
- add a file sites.txt into that folder
- in the file have a line containing the absolute path to your Python site-packages folder
- restart the IDE

But I have an error:

[error] script [ 10000messages ] stopped with error in line 12
[error] TypeError ( find_module() takes exactly 3 arguments (2 given) )
[error] --- Traceback --- error source first
line: module ( function ) statement
489: pkgutil ( find_loader ) TypeError: find_module() takes exactly 3 arguments (2 given)
594: pkgutil ( get_data ) File "C:\Users\druid\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\pkgutil.py", line 478, in get_loader
6: __init__ ( <module> ) _replaces = pkgutil.get_data(__name__, 'data.bin').decode('utf8').split('\x00')
37: __init__ ( import_module ) File "C:\Python27\lib\site-packages\faker\providers\internet\__init__.py", line 6, in <module>
45: loading ( find_available_locales ) provider_module = import_module(provider_path)
15: config ( <module> ) AVAILABLE_LOCALES = find_available_locales(PROVIDERS)
11: factory ( <module> ) from faker.config import AVAILABLE_LOCALES, DEFAULT_LOCALE, PROVIDERS
1: __init__ ( <module> ) from faker.factor
y import Factory # noqa F401
12: main ( <module> ) from faker import Faker
[error] --- Traceback --- end --------------


from faker import Faker
faker = Faker()

Question information

English Edit question
SikuliX Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
Nick (3rdunknown) said :
Revision history for this message
Best RaiMan (raimund-hocke) said :

apparently, the Python module pkgutil (used inside faker) is not compatible with Jython 2.7.1

Python modules, that are itself written completely in Python language level 2.7, but rely on the Python eco-system, might not work in the Jython environment.

I have no idea for a solution, besides running the Python stuff in a Python subprocess and exchange data with files.
This is an option, if the thing is not time critical.

Revision history for this message
Nick (3rdunknown) said :

@RaiMan thanks for your fast answer.

I found another PIP fake data generator that works very good "fake-data"

Revision history for this message
Nick (3rdunknown) said :

Thanks RaiMan, that solved my question.

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

thanks for feedback