nomissnigghih
Posts: 4
Joined: Mon Jul 02, 2012 5:51 am

SyntaxError: expected path separator ([)

Thu May 16, 2013 8:48 pm

Hi,

I am experiencing a problem with accessing a google drive spreadsheet from my pi with gspread. Using the following code
>>> import gspread
>>> gc = gspread.login('username', 'password')
>>> spreadsheet=gc.open('Spreadsheet')
>>> Log_sheet = spreadsheet.worksheet("Sheet1")
>>> Log_sheet.acell('B1').value
'Value @ B1'

I have tried using the same code in the command line from my computer and it works fine with the result above.

The error happens on the pi after the line >>>Log_sheet = spreadsheet.worksheet("Sheet1")

Can anyone help?

ERROR
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.1/dist-packages/gspread/models.py", line 123, in worksheet
self._fetch_sheets()
File "/usr/local/lib/python3.1/dist-packages/gspread/models.py", line 62, in _fetch_sheets
self._sheet_list.append(Worksheet(self, elem))
File "/usr/local/lib/python3.1/dist-packages/gspread/models.py", line 168, in __init__
self.version = element.find(_ns("link[@rel='edit']")).attrib['href'].split('/')[-1]
File "/usr/lib/python3.1/xml/etree/ElementTree.py", line 305, in find
return ElementPath.find(self, path)
File "/usr/lib/python3.1/xml/etree/ElementPath.py", line 186, in find
return _compile(path).find(element)
File "/usr/lib/python3.1/xml/etree/ElementPath.py", line 176, in _compile
p = Path(path)
File "/usr/lib/python3.1/xml/etree/ElementPath.py", line 93, in __init__
"expected path separator (%s)" % (op or tag)
SyntaxError: expected path separator ([)

I have tried reinstalling elementtree, I have also tried python 3.1, still no joy

please can anyone help?

timhoffman
Posts: 85
Joined: Sat Nov 05, 2011 11:31 pm

Re: SyntaxError: expected path separator ([)

Fri May 17, 2013 1:11 am

Check you are using the same version of python on the working machine.

nomissnigghih
Posts: 4
Joined: Mon Jul 02, 2012 5:51 am

Re: SyntaxError: expected path separator ([)

Fri May 17, 2013 3:38 pm

Tim,

Thank you for replying yes its the same version using python -v to check

timhoffman
Posts: 85
Joined: Sat Nov 05, 2011 11:31 pm

Re: SyntaxError: expected path separator ([)

Sat May 18, 2013 1:42 pm

Check and see if you have lxml installed on your desktop. Your XML parsing may be devolving to elementree without lxml present and hence the error.

nomissnigghih
Posts: 4
Joined: Mon Jul 02, 2012 5:51 am

Re: SyntaxError: expected path separator ([)

Sat May 18, 2013 2:02 pm

Thank you Tim, I have checked on the pi and I have lxml installed

/usr/lib/pyshared/python2.6/lxml
/usr/lib/python2.6/dist-packages/lxml

Please could you provide a little more on what believe the problem might be, I perhaps didn't understand?

corranwebster
Posts: 10
Joined: Fri Mar 29, 2013 12:59 am

Re: SyntaxError: expected path separator ([)

Tue May 21, 2013 2:52 am

It looks like you have lxml installed for Python 2.6, but not Python 3.1.
This means that your Python 3 code will be getting the standard library version of elementree, rather than lxml's improved one, which may account for the error that you are seeing.
Your options would seem to be to install lxml for Python 3, or to install gscript in Python 2.6 and run your code with Python 2.

-- Corran

corranwebster
Posts: 10
Joined: Fri Mar 29, 2013 12:59 am

Re: SyntaxError: expected path separator ([)

Tue May 21, 2013 2:54 am

In the interest of avoiding clarity: I mis-typed 'gscript' where I meant 'gspread' in the previous post.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: SyntaxError: expected path separator ([)

Tue May 21, 2013 6:38 pm

Try

Code: Select all

Log_sheet=gc.open('Spreadsheet').sheet1
Dave.
Apple say... Monkey do !!

nomissnigghih
Posts: 4
Joined: Mon Jul 02, 2012 5:51 am

Re: SyntaxError: expected path separator ([)

Tue May 21, 2013 9:36 pm

HI Thank you for your replies. I have couldn't work it out, I pullout the SD card, reloaded the Debian Wheezy (latest version) and started over. All working now. I have 2.7 and 3.1, after installing GSPREAD, both worked as expected from IDLE able to login and extract values.

I can confirm the latest Debian Wheezy works with GSPREAD, I did have a very early version on my PI and have been installing alsorts of software trying different combinations.

BTW the latest version has a colour cusor - I was impressed! (Little things)

Return to “Python”