importing twilio in sikuliX

Asked by Depta Paul

I want to use automatic message sender like twilio at middle of my code.
To install twilio there is a pip command "pip install twilio" in python.
But I want to use this in Sikulix.
I have also use site.txt where python2.7 package directory is written.
after adding site.txt in appdata, I can import twilio.
But when I import like this:

from twilio.rest import Client

it shows some error like this:
[error] script [ Documents ] stopped with error in line 1
[error] Error caused by: Traceback (most recent call last):
.....................................................................................................
.....................................................................................................
.............

But I can use "from twilio.rest import Client" in python without any problem.
So, I am badly in need of a help. Please help me and take thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Depta Paul
Solved:
Last query:
Last reply:
Revision history for this message
TestMechanic (ndinev) said :
#1

You should be aware that Sikuli uses jython not python

I would suggest 2 possible approaches:

1. Write a simple command line python tool that uses twilio in the way you need and then to drive it via Sikuli system commands

2. You may try to use twilio lib directly
  - open Sikuli IDE and create empty sikuli script twilio_test.sikuli - a .py file will appear inside this directory .
  - on the top line type 'import twilio'
  - download tgz file form https://pypi.python.org/pypi/twilio and unpack it in some temp folder
  - from within twilio-6.10.0 folder copy twilio folder inside twilio_test.sikuli folder so you will end up with structure like this

twilio_test.sikuli
   twilio_test.py
   twilio

Now twilio_test.sikuli script will compile ok from within SikuliIDE. But you need to go and test if this will work for you

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

@TestMechanic
Thanks for the possible solutions.

Python Modules written in Python language only (no dependencies to native libraries / C-based stuff) and compatible with language level 2.7 should work with Jython/SikuliX.

If you have such a package, then you can do things like shown here
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-python
to avoid the duplicating of the Python modules in your .sikuli script folders.

Revision history for this message
Depta Paul (deptapaul) said :
#3

Thank you very much @TestMechanic and @Raiman.
There is also a possible solution. I have convert my whole project into JAVA and everything is working like a charm.
By the way.. Once again thank you.