问题
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 errorImportError: 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 sayingImportError: No module named gspread
I also tried using cx_freeze to create the executable. The command I use ispython 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
来源:https://stackoverflow.com/questions/34438105/include-gspread-module-using-py2exe-pyinstaller