Search code examples
pythonraspberry-pigspread

AttributeError: 'module' object has no attribute 'authorize'


I want to reporting something to google spreadsheet, my code for example:

import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds']

credentials = ServiceAccountCredentials.from_json_keyfile_name('con.json', scope)

gc = gspread.authorize(credentials)


wks = gc.open("temperatura")

ws = wks.get_worksheet(0)



ws.update_acell('A1','IT WORKS!')

I get error:

gc = gspread.authorize(credentials) AttributeError: 'module' object has no attribute 'authorize'

Thanks for feedback

regards malin


Solution

  • Your code seems okay. Why don't you try installing gspread module again.

    You can create a vitual environment in a folder and install all the required packages there.

    This might help you run all your projects in a virtual environment without affecting other modules or packages.

    $pip install virtualenv

    $ cd my_project_folder $ virtualenv my_project

    $cd my_project $source bin/activate

    now you can install all your modules and packages.

    http://docs.python-guide.org/en/latest/dev/virtualenvs/