I'm calling a sikuli function, inside Sikuli IDE, but I get this error "NameError: global name 'openApp' is not defined"...
If I try to do openApp('calc') in a new Sikuli blank file, it works, but if I use in another .sikuli file like:
def sample():
import myLib
# my Lib is .py file that I've created and put it on sikuli-script.jar
var = somevalue
myLib.myFunction(something)
openApp('calc')
I get the error with "openApp" and other sikuli funcions like "Key" (ex: Key.ENTER) too...
Hope I had explained that well
By default, Sikuli will insert a from sikuli import * into all main files. This error tends to occur when you import sikuli modules. If you are importing modules, you will need to add the import manually. See the documentation for more advice.
If your tests are in the same folder basically you can do,
import testName
reload(testName)
from testName import *
This will import your test and execute it's content.
testName should be name of the file without .sikuli extension
I ran into a similar problem was solved by putting from sikuli import * at the first line of any file you are importing. I hope this helps!
I only mentioned this, because with the imported files, I had the greatest overall success with this one, and it became habit to make this the first line.
Related
Fast Ai uses a very unconventional style of from fastai import * etc.
I for one do not like it so was painstakingly identifying each import in the chapter 2 of the fastai book but ran into the error
AttributeError: 'Learner' object has no attribute 'fine_tune'
However, when I then go and do
from fastbook import *
it works. This is a very odd behavior in that something is done to the cnn_learner class or the module that contains it making it have the fine_tune method if the above import is done.
I would like to avoid this style of coding, so what should I do to load the correct version of Learner?
I just faced the exact same issue. After looking at one of their tutorial I saw that the cnn learner is not imported from the expected package.
from fastai.vision.all import cnn_learner
# rather than
from fastai.vision.learner import cnn_learner
calling the fine_tune method then works as expected !
Fastai does a lot of monkey patching. Not only to its own imports but also to other libraries such as pathlib or torch. I personally don't like this style of coding either but it is what it is.
I would highly recommend creating a separate environment (e.g. through conda), install fastai there and use their from ... import *. I have tried to work around these imports in the past but since you don't know (unless you dig into source) where/what has been monkey patched, you will be running into missing attribute and similar errors all over the place.
Also, it doesn't play nice with some other libraries. I remember having hard time making it work with opencv due to package dependencies, where installing opencv broke some of the fastai's functionality (which I have only found later) due to overriding something that has been patched by fastai in some external library.
When looking at the Examples in the pub.dev/packages, the code for some contained with one page, while the more advanced ones are not showing all the code. For example, in the firebase_auth package, the Example shows the main.dart file, while the most important code is probably at the other two imported files:
import './register_page.dart';
import './signin_page.dart';
My question - How do I see the two files?
Thanks, Gal.
You can use this package by call some function and use IDE to jump to definition for example command + click in VS code.
Or you can open library file in directory flutter_dir/.pub-cache/hosted/pub.dartlang.org/name_of_lib/lib
In the PyInstaller docs they demonstrate the use of eval_statement() and exec_statement() which call eval() or exec() in a new instance of Python. But they don't say why you would want to run your code in a separate instance.
For example, why couldn't their example of:
from PyInstaller.utils.hooks import exec_statement
mpl_data_dir = exec_statement(
"import matplotlib; print(matplotlib._get_data_path())"
)
datas = [ (mpl_data_dir, "") ]
not just be:
import matplotlib
datas = [(matplotlib._get_data_path(), "")]
I've tried doing this with my own library and it doesn't seem to do it any harm. So why the extra complexity? Why do all the other hooks included in PyInstaller use the 1st method?
All the hooks use the first method in case of path and environment manipulations. What happens if matplotlib changes sys.path or some other environmental manipulation that could mess with the build process? Using a separate python instance means this won't happen.
I have the following include/import in my "main.jl" file:
include("Global.jl")
import .Global
As importing this module takes some time and it is always the same on every execution, I would like test in advance if .Global exists so I can bypass the include/import.
The idea is that I can edit all changes in my text editor and use the interactive console to reload the whole program but waiving that step if it is already there.
import X is already basically a no-op if X has already been imported.
The problem is when you do the include you are defining a new module also called X so import tries and loads the new one.
I suggest thus converting your module into a package,
adding it to your environment, then just doing import X
You can use isdefined(Main, :ModuleName) (don't forget the colon).
if !isdefined(Main, :Global)
include("Global.jl")
import .Global
end
For the same question when you are using a package named "MyPackage":
if !isdefined(Main, :MyPackage)
using MyPackage
end
Can not change the JDK, tried downloading javafx.jar and it did not work either. what should I do?
You can replace javafx.util.Pair (using import javafx.util.Pair) by AbstractMap.SimpleEntry (using import java.util.AbstractMap) if it is the only class from javafx