1
我创建使用gspread和的oauth2模块py2exe缺少模块:oauth2client.client和gspread模块
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
credentials = SignedJwtAssertionCredentials("client_email","private_key", "https://spreadsheets.google.com/feeds")
gc = gspread.authorize(credentials)
spreadsheet = gc.open_by_key("spreadsheet_id")
worksheet = spreadsheet.worksheet("sheet_name")
lstoforders = worksheet.get_all_values()
...some extra code...
当我运行此代码为.py文件一切工作顺利以下Python脚本。然而,当我尝试使用py2exe把它打包成一个可执行的Windows程序,我得到下面的输出
The following modules appear to be missing
['ElementC14N', 'IronPythonConsole', 'System', 'System.Windows.Forms.Clipboard', '_scproxy', 'ca_certs_locater', 'clr', 'console', 'email.FeedParser', 'email.Message', 'email.Utils', 'google.appengine.api', 'google.appengine.api.urlfetch','google3.apphosting.api', 'google3.apphosting.api.urlfetch', 'http', 'modes.editingmodes', 'oauth2client.client' 'pyreadline.keysyms.make_KeyPress', 'pyreadline.keysyms.make_KeyPress_from_keydescr', 'pyreadline.keysyms.make_keyinfo', 'pyreadline.keysyms.make_keysym', 'startup', 'urllib.parse']
因此,当我尝试运行生成的exe文件,我得到以下错误
Traceback (most recent call last):
File "gspread_to_autocomplete_json.py", line 2, in <module> ImportError: No module named oauth2client.client
它看起来好像py2exe找不到gspread和oauth2client.client模块。这些模块安装在我的机器上。
有没有人有线索为什么会发生这种情况?
谢谢。
尼古拉
你可能要考虑[这个答案](http://stackoverflow.com/q/34438105/5687152)作为整合到我上面写的内容 – mabe02