1

I installed gspread library and ran pip install gspread and followed all the instructions on this page. I've read many other threads on this issue and have checked that no file named gspread.py exists in my entire rapi 3b. I am running on python 2.7.9. My code never gets past

import os
import time
import RPi.GPIO as GPIO
import glob
import tkinter as tk
import json
import sys
import time
import datetime
import gspread
from oauth2client.service_account import ServiceAccountCredentials

At import gspread, it throws ImportError: No module named 'gspread'. If I delete import gspread it throws the same error on oauth2client; ImportError: No module named 'oauth2client'.

My suspicions are that I have it installed in the wrong place, but I am new to pi and do not know too much about paths.

Please help... Why is it throwing these errors when I have these libraries installed?

  • 1
    many times this is because you ran pip for python2 and are running the script with python3 or visa versa. – Chad G Jul 10 '18 at 23:26
  • Hey @ChadG thanks for the quick response, I only have python 2.7.9 on the pi, so I don't think that it is that. Right? – Leo G Jul 11 '18 at 1:40
  • Does python3 then import gspread work? If so gspread is installed for Python version 3. Similarly python2 then import gspread. – joan Jul 11 '18 at 6:39
  • python3 then import gspread doesn't work, throws the same ImportError: No module named 'gspread'. However, python2 then import gspread throws no errors and returns nothing. Thanks for the response @joan – Leo G Jul 11 '18 at 17:45
  • @LeoG It looks like you are running under Python 3 rather than Python 2 when you get the import error. You need to check that you are actually invoking Python 2. – joan Jul 11 '18 at 19:01
2

Fixed this problem. I was running under python 3 but oauth2client and gspread were installed under python 2. To fix this, I ran pip3 install on gspread and oauth2client and all is running smoothly now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.