Reputation: 4223
I'm testing newly installed 'xlrd' package :
#!/usr/bin/env/python
import xlrd
wb = xlrd.open_workbook('D:\excel\test.xls')
print (wb.sheets())
I run it through IDLE (Windows 7) and I get the following error message:
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "D:\excel\testxls.py", line 3, in <module>
import xlrd
File "C:\Program Files (x86)\Python33\lib\site-packages\xlrd\__init__.py", line 1187
print "EXTERNSHEET(b7-):"
^
SyntaxError: invalid syntax
>>>
Any idea on this issue?
Thanks!
Upvotes: 6
Views: 7170
Reputation: 679
It seems that there is an error with your installation or usage.
The first thing I have seen is that print 'something'
is not used in python3 but print('something')
. And the error shown in the code is because of using python2 with python3.
At the time of writing this answer the version of xlrd is 0.9.4. This version is compatible with both python2 and python3.
So I suggest you to update the xlrd module so that you will not face any further errors. You can do that by following any of the following steps:
$ pip install xlrd
or
$ easy_install xlrd
Upvotes: 0
Reputation: 159
It seems like your xlrd
file is corrupted. So update it by using the following command :
$ python3 -m pip install --upgrade xlrd
Upvotes: 9
Reputation: 5537
XLRD is available for Python3.
You can get it with sudo apt-get install python3-xlrd
or with sudo pip3 install xlrd
As you can see it's available here on pypi : https://pypi.python.org/pypi/xlrd
Here's a dump of my console output :
sudo apt-get install python3-xlrd
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-xlrd is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 574 not upgraded.
Upvotes: 0