Unable to import module Requests on Sikulix IDE 2.0.5

Asked by Guillermo

I have a structure of multi-sikuli-modules set up, with an "API" module that makes use of an external module ( 'requests'), i.e.:
 - test1.sikuli
 - test2.sikuli
 - API.sikuli -> tools.py has `import requests`

I also have set up a, so to say, entry point, "framework.sikuli", that sequentially loads my modules and then launches them:
```
test_modules = [
    r"API.sikuli",
    r"test1.sikuli",
    r"test2.sikuli"]

for module in test_modules:
     if not module in sys.path:
         sys.path.append(module)
    module = module.replace(".sikuli", "")
    print("Loading Module %s " % module)
    module_obj = __import__(module)
    globals()[module] = module_obj
```

If I remove the "API.sikuli" from test_modules array, when I run the framework.sikuli it fails afterwards (because test1 and test2 need the API), but having it there I get this error:
Loading Module API
[error] script [ test_framework ] stopped with error in line 220
[error] ImportError ( !!WHILE IMPORTING!! No module named requests )
[error] --- Traceback --- error source first
line: module ( function ) statement
5: API ( <module> ) import requests
220: main ( <module> ) module_obj = __import__(module)
[error] --- Traceback --- end --------------

What am I doing wrong?

I'm running Sikulix IDE 2.0.5, for what it's worth.

Thank you in advance

Question information

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

where is the "external" module request?

Can it be found on sys.path?

Revision history for this message
Guillermo (ggonmar) said :
#2

It is a module that I install by `npm install requests`.
I don't know if it is in sys.path - where would I check that? :/

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

npm means it is some javascript stuff, which surely cannot be imported into Python scripts.

So IMHO this error has no solution.

Revision history for this message
Guillermo (ggonmar) said :
#4

Apologies, I meant pip!

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

I could not check, wether requests can be used with the SikuliX Jython interpreter (not possible if its uses C-based stuff from Python).

In any case, you have to take care, that the folder where pip installs modules is on SikuliX's sys.path

Can you help with this problem?

Provide an answer of your own, or ask Guillermo for more information if necessary.

To post a message you must log in.