Include gspread module using py2exe, pyinstaller

≡放荡痞女 提交于 2019-12-25 09:59:12

问题


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

来源:https://stackoverflow.com/questions/34438105/include-gspread-module-using-py2exe-pyinstaller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!