sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #09180
[Question #189637]: exception when "import urllib2"
New question #189637 on Sikuli:
https://answers.launchpad.net/sikuli/+question/189637
I am running version r930, portable, java 32 bit, windows 2008 r2. I am having some exceptions when trying to import urllib2.
here is my code:
*****CODE*****
import urllib2
response = urllib2.urlopen('http://sikuli.org/')
html = response.read()
print html
*****END CODE*****
it ran ok the first time, the html printed in the "Message" tab, but it always throw exception when I ran it again, the except is below:
*****EXCEPTION 1*****
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
0
[error] Stopped
[error] An error occurs at line 1
[error] Error message: Traceback (most recent call last):
File "C:\Users\ADMINI~1\AppData\Local\Temp\2\sikuli-tmp79051097327001098.py", line 1, in
import urllib2
File "C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\urllib2.py", line 92, in
File "C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\httplib.py", line 70, in
File "C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\mimetools.py", line 6, in
File "C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\tempfile.py", line 33, in
File "C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\sikuli\SikuliImporter.py", line 45, in load_module
File "C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\sikuli\SikuliImporter.py", line 29, in _load_module
ImportError: Errors in loading sikuli module: random
'module' object has no attribute 'randint'
- HOW TO FIX? Try adding "from sikuli import *
" in the module.
*****END EXCEPTION 1*****
After got this exception, I can't even save the script, whenever I save script, the below exception occur:
******EXCEPTION 2*****
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.(Throwable.java:181)
at java.lang.Exception.(Unknown Source)
at java.lang.RuntimeException.(Unknown Source)
at org.python.core.PyException.(PyException.java:46)
at org.python.core.PyException.doRaise(PyException.java:219)
at org.python.core.Py.makeException(Py.java:1225)
at org.python.core.Py.makeException(Py.java:1229)
at org.python.core.Py.makeException(Py.java:1233)
at sikuli.SikuliImporter$py._load_module$5(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\sikuli\SikuliImporter.py:32)
at sikuli.SikuliImporter$py.call_function(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\sik
uli\SikuliImporter.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at sikuli.SikuliImporter$py.load_module$6(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\sikuli\SikuliImporter.py:45)
at sikuli.SikuliImporter$py.call_function(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\sikuli\SikuliImporter.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
at org.python.core.PyFunction.__call__(PyFunction.java:387)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
at org.python.core.PyMethod.__call__(PyMethod.java:211)
at org.python.core.PyMethod.__call__(PyMethod.java:201)
at org.python.core.PyMethod.__call__(PyMethod.java:196)
at org.python.cor
e.imp.loadFromLoader(imp.java:513)
at org.python.core.imp.find_module(imp.java:448)
at org.python.core.imp.import_next(imp.java:713)
at org.python.core.imp.import_name(imp.java:824)
at org.python.core.imp.importName(imp.java:884)
at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
at org.python.core.PyObject.__call__(PyObject.java:357)
at org.python.core.__builtin__.__import__(__builtin__.java:1173)
at org.python.core.imp.importFromAs(imp.java:978)
at org.python.core.imp.importFrom(imp.java:954)
at tempfile$py.f$0(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\tempfile.py:461)
at tempfile$py.call_function(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\tempfile.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:386)
at org.python.core.util.importer.importer_load_module(importer.java:109)
at org.python.modules.zipimport.zipimporter.zipimport
er_load_module(zipimporter.java:161)
at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)
at org.python.core.imp.loadFromLoader(imp.java:513)
at org.python.core.imp.find_module(imp.java:467)
at org.python.core.imp.import_next(imp.java:713)
at org.python.core.imp.import_name(imp.java:824)
at org.python.core.imp.importName(imp.java:884)
at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
at org.python.core.PyObject.__call__(PyObject.java:357)
at org.python.core.__builtin__.__import__(__builtin__.java:1173)
at org.python.core.imp.importOne(imp.java:903)
at mimetools$py.f$0(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\mimetools.py:236)
at mimetools$py.call_function(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\mimetools.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.
java:18)
at org.python.core.imp.createFromCode(imp.java:386)
at org.python.core.util.importer.importer_load_module(importer.java:109)
at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)
at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)
at org.python.core.imp.loadFromLoader(imp.java:513)
at org.python.core.imp.find_module(imp.java:467)
at org.python.core.imp.import_next(imp.java:713)
at org.python.core.imp.import_name(imp.java:824)
at org.python.core.imp.importName(imp.java:884)
at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
at org.python.core.PyObject.__call__(PyObject.java:357)
at org.python.core.__builtin__.__import__(__builtin__.java:1173)
at org.python.core.imp.importOne(imp.java:903)
at cgi$py.f$0(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\cgi.py:1071)
at cgi$py.call_funct
ion(C:\app\Sikuli-r930-win32\Sikuli-IDE\sikuli-script.jar\Lib\cgi.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:386)
at org.python.core.util.importer.importer_load_module(importer.java:109)
at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)
at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)
at org.python.core.imp.loadFromLoader(imp.java:513)
at org.python.core.imp.find_module(imp.java:467)
at org.python.core.imp.import_next(imp.java:713)
at org.python.core.imp.import_name(imp.java:824)
at org.python.core.imp.importName(imp.java:884)
at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
at org.python.core.PyObject.__call__(PyObject.java:357)
at org.python.core.__builtin__.__import__(__builtin__
.java:1173)
at org.python.core.imp.importOne(imp.java:903)
at org.python.pycode._pyx169.f$0(:202)
at org.python.pycode._pyx169.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
at org.sikuli.ide.SikuliPane.convertSrcToHtml(SikuliPane.java:260)
at org.sikuli.ide.SikuliPane.writeSrcFile(SikuliPane.java:281)
at org.sikuli.ide.SikuliPane.saveFile(SikuliPane.java:290)
at org.sikuli.ide.SikuliIDE$FileAction.doSave(SikuliIDE.java:1427)
... 55 more
*****END EXCEPTION 2*****
Appreciated any help. Thanks.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.