Sikulix install - jython - python

I need to test unity 3d app on mobile device (or emulator). I do not want to press on buttons using coordinates only, so I want to use Sikuli. I will describe steps that I have already done:
Downloaded and installed Sikuli v1.1.1
Installed java 32bit
Installed jython 2.7.0
jython added as interpreter in my project in pyCharm
sikulixapi is run
Copied Sikuli lib from appData to jython folder
Created Python file and added imports
And when I try to run project I receive this error:
D:\jython2.7.0\bin\jython.exe -Dpython.path=D:\python_projects\sikuli_test D:/python_projects/sikuli_test/test_sikuli.py
Tra**ceback (most recent call last):
File "D:/python_projects/sikuli_test/test_sikuli.py", line 1, in <module>
from sikuli import Region
File "D:\jython2.7.0\Lib\sikuli\__init__.py", line 5, in <module>
from org.sikuli.basics import Debug
ImportError: No module named sikuli
Process finished with exit code -1**
What am I doing wrong?

The following works for me:
import org.sikuli.script.SikulixForJython
before
from sikuli import *

In your jython project interpreter, set the environment variables path to where your sikuli jar is placed. That should fix it.
Also make sure to use this in your code
import org.sikuli.script.SikulixForJython
from sikuli import *

Related

Embeddable Python - ModuleNotFoundError for project folders

I'm trying to create an embedded python for my project.
I downloaded the portable python 3.7.6
Copied the folders from my main python installation (Lib, Scripts, include, DLLs etc..)
Added them to the PTH file like so :
python37.zip
.
Lib
Lib/site-packages
Scripts
include
DLLs
doc
libs
Tools
tcl
# Uncomment to run site.main() automatically
#import site
and when I tested it, I tried to run a project with the following structure :
By running the command (using the embedded python):
G:\GitHub\VRoscopy\VRoscopy\Conversion\python\python.exe main.py
I get the following error :
> Traceback (most recent call last):
> File "mymain.py", line 1, in <module>
> import folder.module as m ModuleNotFoundError: No module named 'folder'
However, when I try running the system python everything works normally.
Hope anyone can help me, thanks
The problem was solved by adding the project files to the PTH file, and uncommenting the "import site" like follows :
python37.zip . ../invesalius
../invesalius/* # <----- added this line
Lib
Lib/site-packages
Scripts
include
DLLs
doc
libs
Tools
tcl
# Uncomment to run site.main() automatically
import site

ImportError: No module named _analog_swig

I am having issues getting python to import the _analog_swig gnuradio module in order to run gnuradio code on a Windows 8.1 64bit machine.
Some background: I am running Python 2.7.10 (installed in C:\Python27) and have installed the latest gnuradio binary (v3.7.11.1/v1.3 64-Bit Any CPU) from here: http://www.gcndevelopment.com/gnuradio/downloads.htm. I have installed gnuradio to C:\Program Files\GNURadio-3.7 .
I can run gnuradio companion and run flowgraphs from GRC successfully (which calls "C:\Program Files\GNURadio-3.7\bin\run_gr.bat" gnuradio-companion.py).
I have added & verified the following system variables are set:
Path: C:\Program Files\GNURadio-3.7\bin
PYTHONPATH: C:\Program Files\GNURadio-3.7\lib\site-packages
GRC_BLOCKS_PATH: C:\Program Files\GNURadio-3.7\share\gnuradio\grc\blocks
Now to the problem: If I run e.g. CMD and type:
python C:\test\top_block.py
I am returned the following ImportError:
File "C:\test\top_block.py", line 22, in <module>
from gnuradio import analog
File "C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog\__init__.py", line 33, in <module>
from analog_swig import *
File "C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog\analog_swig.py", line 17, in <module>
_analog_swig = swig_import_helper()
File "C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog\analog_swig.py", line 16, in swig_import_helper
return importlib.import_module('_analog_swig')
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _analog_swig
The folder content of C:\Program Files\GNURadio-3.7\lib\site-packages\gnuradio\analog is as follows:
Comparing this to the folder content on a linux machine, which has a working install of gnuradio that works with python as I want it:
The difference seems to be that the folder in windows contains only a _analog_swig.pyc file, whereas the folder in linux contains a _analog_swig_.so file.
Any idea why the _analog_swig module can apparently not be imported in windows?
My plan is to be able to run gnuradio code directly from my python interpreter and being able to create compiled gnuradio executables so any help on how this could be fixed is much appreciated.
I've been struggling with this for the past few days, but I finally figured it out. I was trying to run GnuRadio Companion generated code in IDLE and also in PyCharm. I kept failing miserably with this same error. I finally figured it out:
-As Flexo says, the PYD file (_analog_swig.pyd) is actually a Windows DLL. The error makes it sound like Python is not finding that file, but that is not at all what was happening. The PYD file, being a DLL, has dependencies itself. Python is able to find _analog_swig.pyd just fine, but it could not find the DEPENDENCIES of that library.
-To verify if that's what wrong in your installation, download and use DependencyWalker (Google it) to check if your system can find the dependencies to _analog_swig.pyd.
-The fix for me was to add the GnuRadio-3.7/bin folder to my PATH environment variable. Inside that folder are a number of DLLs that the _analog_swig.pyd library needs to load. If you don't have the folder in your PATH, the module will fail to load in Python and throw the error you see above.
-I see that you verified that this folder is in your PATH, so this is apparently not the same problem, although your symptoms are exactly the same as mine. i.e. the GRC code would run just fine when you start with "run_gr.bat", but not when you run from a normal CMD window.
Hopefully that helps someone else that wants to use GNURadio Python code on Windows.
Friend,
As you mentioned, the GNU Companion calls \bin\run_gr.bat gnuradio-companion.py. That batch script does quite a bit of work on windows environment variables (try opening it in a text editor if you're curious).
In a sense, the run_gr.bat script puts together a temporary, custom python workspace for gnuradio so it can import anything it needs. It receives python scripts to run in this environment as command line arguments; hence, you can use it to run any GNU radio python code you want in your windows command prompt. Generally, you would call
<gnuradio_install_path>\bin\run_gr.bat <gnu_radio_code>.py
To test your import, you can try
# test.py
from gnuradio import analog
try calling the following from the command prompt, in the test.py directory:
<gnuradio_install_path>\bin\run_gr.bat test.py

Python 3.4 Openpyxl error

I'm having a problem with Python when importing module openpyxl. I'm using Python 3.4 and have followed instructions and managed to install the module.
When I'm importing the module like this:
from openpyxl import workbook
It gives me the following error:
Traceback (most recent call last):
File "C:/Python34/test.py", line 1, in <module>
from openpyxl import workbook
ImportError: No module named 'openpyxl'
I installed the module following this step-by-step method:
I went in to the control panel - system and security - System - advanced system - system - enviroment variables - find path in the scroll bar and write in at the end where Python is installed. After this is done you can go in CMD and write python and it will find it.
In your modulepackage you downloaded there is a setup.py look up the directory of this.
Go to the CMD and write in cd followed by the directory.
Then write python setup.py and the setup will begin.
After the setup is done go in to the CMD and write python and then import "module name" if no error is shown the setup is finished.
Help me Stackoverflow, you're my only hope!

Compiling python script with a dependable python script using pyinstaller - QT related error

I need to make a python executable in ubuntu, of my code, which has got a python dependency of another python class.
dbscan.py
class dbscan:
#some code goes here
helloworld.py
import dbscan
from dbscan import *
#again some more code goes here
I am using pyinstaller to create the executable,
pyinstaller helloworld.py
If I use the same for a python program which doesn't uses classes from other python files it runs just fine, but when i create executable with a case like above I get this error, when i run the executable
File "<string>", line 36, in <module>
ImportError: No module named QtCore

python pyjamas install on debian

i have installed pyjamas on debian
http://pyjs.org/getting_started.html
however my program does not find the module, what could be the problem, i have installed pyjamas correctly using apt-get
krisdigitx-virtual-machine ~ # python jamas.py
Traceback (most recent call last):
File "jamas.py", line 3, in <module>
from pyjamas import Window
ImportError: No module named pyjamas
krisdigitx-virtual-machine ~ #
#!/usr/bin/env python
from pyjs import Window
from pyjs.ui import RootPanel, Button
from pyjs.ui import HTML
def greet(sender):
Window.alert("Hello Krishna!")
b = Button("click me", greet)
Rootpanel().add(b)
After some research:
i had to do pyjsbuild jamas.py to get the output directory, however it gives me a new error
jamas TypeError: jamas.RootPanel().add is not a function
Since you get an
ImportError: No module named pyjamas
you may need to add the module's path to $PYTHONPATH with
export PYTHONPATH=$PYTHONPATH:/usr/share/pyjamas/library
Please go to http://pyjs.org/GettingHelp.html
The first link "Getting Started" is a detailled walkthrough for an installation to start from scratch. Basically, what it says there is: Get the up-to-date source code from the git repository.
All steps to get Pyjs and Pyjs Desktop running are described in the Wiki article in the necessary detail, but still concise enough.

Categories