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