Unable to import xlrd: Syntax error

Asked by Ashish

Unable to import xlrd: Syntax error

Error Message:
[error] script [ Untitled ] stopped with error in line 1
[error] SyntaxError ( ('no viable alternative at input \'"PK\\x03\\x04"\'', ('C:\\Users\\abcd\\Documents\\SikuliX\\sikulix.jar\\Lib\\xlrd\\__init__.py', 397, 16, ' if peek == b"PK\\x03\\x04": # a ZIP file\n')) )

I am using the following versions:
Sikulix 1.1.0
jython-standalone-2.5.4-rc1.jar
Java6

Limitations: i cannot upgrade the java as it is restricted by my admin.

xlrd folder is SikuliX/Libs

Please suggest some workaround as i am new to sikuli and unable to proceed:(

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Then you have a problem :-(

Does SikuliX as such work?
What system are you running on?

For what exactly do you need xlrd?
Possible to export the .xls as .cvs and then access the file normally?

Revision history for this message
Ashish (ashishvs21) said :
#2

Sikuli works fine as such.

I need xlrd to read data from excel (.xls).

I am running it on Win7.

Sorry to ask silly question but what is the syntax error in Line 397 of "__init__.py" file.

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

-- what is the syntax error
the xlrd package has an __init__.py, which by convention is executed by the interpreter when a Python modul is loaded.
The code in that line is Python language level 2.7 and hence gives a syntax error, since Jython 2.5 only supports language level 2.5.

you might try with an older version:
https://pypi.python.org/pypi/xlrd/0.7.1

which is compatible with language level 2.5

Take care that the offending xlrd gets out of reach for SikuliX.

if you have problems:
- tell exactly where you have your xlrd folder
- run in the SikuliX IDE
for e in sys.path: print e
... and post the output here

Can you help with this problem?

Provide an answer of your own, or ask Ashish for more information if necessary.

To post a message you must log in.