Question on installing jython project interpreter in Pycharm (for Windows10)

Asked by Paul Weber

Hi RaiMan!
I plan to run autotests on Windows10 (in parallel, I'm trying to do the same on Linux). I am trying according to your instructions (https://sikulix-2014.readthedocs.io/en/latest/scenarios.html) to run the sikulix script through Pycharm. However, I got confused with the installation of the project interpreter (jython 2.7.1) and environment variables. Do I need to prescribe CLASSPATH for Windows10, if so, how and where? How and where to import and install Sikulix modules so that the script runs from Pycharm? How to set the project interpreter and environment variables correctly if this is not a new project? Maybe there is a step-by-step instruction from the Master, how to do it right competently right away? Can I run Sikulix script from under Pycharm on Linux?
My Pycharm version: 2019.1.3 (Community Edition), Build # PC-191.7479.30;
JRE: 11.0.2 + 9-b159.60 amd64;
JVM: OpenJDK 64-Bit Server VM
I would be grateful for any advice!
Firmly press the right!
Regards, Paul!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

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

should get answered.

Revision history for this message
Paul Weber (weber19) said :
#3

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!

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

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

should really get answered ;-)

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

x

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

Did you get further with your experiments?

I will update my PyCharm setup on Windows 10 the next days and add some hints to the docs.

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

docs revised