Question #688198 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/688198

Paul Weber gave more information on the question:
Hi RaiMan!
I'm trying to figure out how to run the sikulix script in Pycharm correctly. I 
try to repeat the steps according to your instructions - 
https://sikulix-2014.readthedocs.io/en/latest/scenarios.html. For this, I 
performed :

1) Download, install and run Jython-2.7.1 (C: \ Jython2.7.1 \
jython2.7.1);

2) Previously installed version of Pycharm:: 2019.1.3 (Community
Edition), Build # PC-191.7479.30; (C: \ Program Files \ JetBrains \
PyCharm Community Edition 2019.1.3 \ bin);

3) Indicated PyCharm to use Jython as an interpreter.
Settings → Progect: PycharmProjects (For current project) → Project Interpreter:
Jython 2.7 C: \ Jython2.7.1 \ jython2.7.1 \ bin \ jython.exe
At the same time, in the same window (PyCharm) you can see the connected 
packages.
I have installed: Cython (0.29.14), certifi (2019.11.28), chardet (3.0.4), idna 
(2.8), jip (0.9.13), pip (20.0.2), py4j (0.10.9) , requests (2.22.0), 
robotframework (3.1.2), setuptools (28.8.0), urllib3 (1.25.8), wsgiref (0.1.2)

4) In PyCharm, I set up the environment for the Python console with SikuliX 
support. In the Python Console window, in the Environment variables field, 
added CLASSPATH:
CLASSPATH = C: \ Users \ User \ AppData \ Roaming \ Sikulix \ 
sikulixapi-2.0.2.jar (and for reliability, the same CLASSPATH wrote in the 
Windows folders - Environment Variables: in User Environment Variables and 
System Variables).
Also deactivated the “Add content roots to PYTHONPATH” and “Add source roots to 
PYTHONPATH” checkboxes in the Python Console window.

5) I do not understand about the valid sikulixapi-2.0.2.jar? I downloaded the 
file “sikulixapi-2.0.2.jar” from the site 
https://raiman.github.io/SikuliX1/downloads.html and installed it in the root 
of the folder where the sikulixide-2.0.2 file was installed (C: \ Users \ User 
\ AppData \ Roaming \ Sikulix).
In the Python Console window, in the Starting script field, I wrote two lines:
import org.sikuli.script.SikulixForJython
and from sikuli import *.

6) In PyCharm, in the tab Run → Edit Configurations ... → (+) Add New 
Configuration → Python →
prescribed Script path: C: \ Users \ User \ PycharmProjects \ testuc2 \ 
testuc2.py →
prescribed Environment variables: PYTHONUNBUFFERED = 1; CLASSPATH = C: \ Users 
\ User \ AppData \ Roaming \ Sikulix \ sikulixapi-2.0.2.jar →
prescribed Python interpreter: Jython 2.7 C: \ Jython2.7.1 \ jython2.7.1 \ bin 
\ jython.exe →
prescribed the Working directory: C: \ Users \ User \ PycharmProjects \ testuc2
The "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" 
checkboxes are also deactivated.

7) However, I encountered problems when running the sikuli script (the script 
is from here https://answers.launchpad.net/sikuli/+question/686680).
Firstly, when creating a new project, the following error was displayed:

New jython executable in 
C:\Users\User\PycharmProjects\testuc2\venv\bin\jython.exe
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState 
(file:/C:/Jython2.7.1/jython2.7.1/jython.jar) to method 
java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of 
org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal 
reflective access operations
WARNING: All illegal access operations will be denied in a future release
Traceback (most recent call last):
  File 
"C:\Users\User\AppData\Local\Temp\tmp9exvvepycharm-management\virtualenv-16.4.3\virtualenv.py",
 line 2567, in <module>
    main()
  File 
"C:\Users\User\AppData\Local\Temp\tmp9exvvepycharm-management\virtualenv-16.4.3\virtualenv.py",
 line 783, in main
    create_environment(
  File 
"C:\Users\User\AppData\Local\Temp\tmp9exvvepycharm-management\virtualenv-16.4.3\virtualenv.py",
 line 1070, in create_environment
    py_executable = os.path.abspath(
  File 
"C:\Users\User\AppData\Local\Temp\tmp9exvvepycharm-management\virtualenv-16.4.3\virtualenv.py",
 line 1601, in install_python
    os.symlink(py_executable_base, full_pth)
AttributeError: 'module' object has no attribute 'symlink'

Secondly, when you run this script
(https://answers.launchpad.net/sikuli/+question/686680), which runs fine
in SikuliXIDE2.0.2, another Error and Warning is displayed:

C:\Jython2.7.1\jython2.7.1\bin\jython.exe -Dpython.path= 
C:/Users/User/PycharmProjects/testuc2/testuc2.py
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState 
(file:/C:/Jython2.7.1/jython2.7.1/jython.jar) to method 
java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of 
org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal 
reflective access operations
WARNING: All illegal access operations will be denied in a future release
Traceback (most recent call last):
  File "C:/Users/User/PycharmProjects/testuc2/testuc2.py", line 1, in <module>
    uc = 
App(r"C:\\Users\\User\\UniversalReader\\UniversalReader-v3.9.22_x64.exe")
NameError: name 'App' is not defined
Process finished with exit code -1 
It is not clear why these warnings appear? And why in this script (where the 
interpreter is Jython) should the name "App" be defined?

8) Why are all the functions (App (), wait (), find (), hover (),
doubleClick (), exists (), sleep (), findAll (), click (), etc.) in
SikuliXIDE2. 0.2 are highlighted in light blue and work great, and in
PyCharm IDE are underlined by a red line? As if the PyCharm IDE and
Jython are not seeing the sikuli.Sikuli module?

9) If you hover over such a name (underlined by a red line) and press Ctrl + 
F1, then a warning like this will be displayed:
“Unresolved reference 'wait'...
This inspection detects names that should resolve but don't. Due to dynamic 
dispatch and duck typing, this is possible in limited but useful number of 
cases. Top-level and class-level items are supported better than instance 
items.” Why?

10) In the PyCharm editor, at the beginning of entering the combination
of characters “cl” (for example, the click () function), the Auto-
Completing Code window will be displayed, where on the left a list of
all possible functions, classes and other names is displayed (where the
combination of characters “cl” is present ), and on the right - the
modules are displayed where these functions, classes and names come
from. So, on the right side of the Auto-Completing Code window, either
nothing is displayed, or just “_builtin_”.

11) However, if you add the sikuli folder from C: \ Users \ User \
AppData \ Roaming \ Sikulix \ Lib to Jython (C: \ Jython2.7.1 \
jython2.7.1 \ Lib \ site-packages), then on the right side of the Auto
window -Completing Code will still be displayed - "sikuli.Sikuli". And
when you run the same sikuli script
(https://answers.launchpad.net/sikuli/+question/686680), after adding
the first line “from sikuli import *”, the script will be partially
executed. At the very least, the selected application will open -
“UniversalReader-v3.9.22_x64.exe”. Part of the functions: App (),
uc.open (), exit () and wait () will be active and will not be
underlined with a red line, as in paragraph 8). And then, PyCharm will
show the following error:

C:\Jython2.7.1\jython2.7.1\bin\jython.exe -Dpython.path= 
C:/Users/User/PycharmProjects/testuc2/testuc2.py
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState 
(file:/C:/Jython2.7.1/jython2.7.1/jython.jar) to method 
java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of 
org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal 
reflective access operations
WARNING: All illegal access operations will be denied in a future release
[error] ImagePath: find: not there: Lebeluc.png
Traceback (most recent call last):
  File "C:/Users/User/PycharmProjects/testuc2/testuc2.py", line 13, in <module>
    mTL = find("Lebeluc.png") # find top left
  Line 2280, in file Region.java
        at org.sikuli.script.Region.find(Region.java:2280)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown 
Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
org.sikuli.script.FindFailed: FindFailed: Lebeluc.png: (0x0) in R[0,0 
1920x1080]@S(0)
  Line 2280, in file Region.java
Process finished with exit code -1

12) And another question, when installing sikulixide-2.0.2.jar for the first 
time, in the SikulixLibs library folder (C: \ Users \ User \ AppData \ Roaming 
\ Sikulix \ SikulixLibs) I have 4 files:
- 2.0.2_202001291526_MadeForSikuliX64W;
- jawt.dll;
- Jintellitype.dll;
- opencv_java342.dll
How many files should there be?
Sorry RaiMan for asking a lot of questions, I want to understand how SikuliX 
works!
And thanks for your understanding!

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to