0

I have created a python application which fetches data from a google spreadsheet and performs the required operation and outputs files with the data accordingly. The application works fine through my ide and the console. I'm using gspread and Tkinter for accessing the google sheets and for the GUI respectively.

However when I try to create it into an exe. I keep running into errors.

First I tried using py2exe but I keep getting the error
ImportError: No module named gspread
My setup.py is

from distutils.core import setup
import py2exe
setup(console = ["app.py"], options={"py2exe":{"includes":["gspread"]}})`

and I run it with the command python setup.py py2exe

I also tried pyInstaller using the command pyinstaller app.py and I get the same error. Although in this case the command executes completely and the exe is created but when I run it the console window flashes saying
ImportError: No module named gspread

I also tried using cx_freeze to create the executable. The command I use is
python setup.py build_exe -s -p gspread,json,oauth2client.client,os

This creates the executable but I get the error

I\O operation failed

for line 187 of my code

credentials = oauth2client.client.GoogleCredentials.get_application_default()
credentials = credentials.create_scoped(['https://spreadsheets.google.com/feeds'])
gc = gspread.authorize(credentials)  #line 187

which I've caught using a try/except block on line 187

user3542154
  • 91
  • 1
  • 2
  • 8
  • The error was that gspread was installed as a .egg in the `Lib\site-packages` folder in the python installation and py2exe does not work with exe files. So I unzipped the egg file and pasted the unzipped gspread folder there and ran the py2exe command and it worked however i still get the error now which I was getting when I used pyInstaller – user3542154 Dec 23 '15 at 15:23
  • stick with pyinstaller and create yourself a spec file. Add gspread to the hidden imports. Come back, if error still persists. Post the build log in case of errors. – kotlet schabowy Jan 05 '16 at 09:41

0 Answers0