簡體   English   中英

sendgrid谷歌應用程序引擎python DistributionNotFound

[英]sendgrid google app engine python DistributionNotFound

我正在將Sendgrid集成到Google App Engine Python項目中。

通過pip安裝Sendgrid,並從shell命令行正常運行。

我已將sendgrid文件夾復制到我的gae項目文件夾中。

使用在外殼程序中可用的相同示例代碼(來自sendgrid-python github頁面),我收到以下錯誤:

Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in call
rv = self.handle_exception(request, response, e)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in call
rv = self.router.dispatch(request, response)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in call
return handler.dispatch()
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(args, kwargs)
File "C:***route", line 260, in post
sg = sendgrid.SendGridClient('username', 'password')
File "C:\appname\sendgrid\sendgrid.py", line 36, in init
self.useragent = 'sendgrid/' + pkg_resources.get_distribution('sendgrid').version + ';python'
File "C:\Program Files\Google\google_appengine\lib\setuptools-0.6c11\pkg_resources.py", line 311, in get_distribution
if isinstance(dist,Requirement): dist = get_provider(dist)
File "C:\Program Files\Google\google_appengine\lib\setuptools-0.6c11\pkg_resources.py", line 197, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "C:\Program Files\Google\google_appengine\lib\setuptools-0.6c11\pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "C:\Program Files\Google\google_appengine\lib\setuptools-0.6c11\pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
DistributionNotFound: sendgrid

謝謝你的幫助!

編輯:我嘗試升級並重新安裝pip和setuptools,還安裝分發和分發。 沒事。 我已經在網上搜索了類似的錯誤,無論是從distributionnotfound還是從pkg_resource都沒有。

編輯2:我沒有使用'pip install sendgrid'進行安裝,而是刪除了sendgrid並通過zip從github sendgrid-python下載zip,然后運行setup.py。 最初的結果是相同的,sendgrid是從shell而不是從GAE運行的。 但是,該zip下載文件包含一個DIST文件夾,如果將其與sendgrid文件夾一起復制到GAE目錄中,則將刪除DistributionNotFound錯誤。 但是,GAE項目沒有發送郵件。

謝謝,希望有人能回答。

多虧了sendgrid-python的支持,該問題得以解決,並且對sendgrid-python進行了更新。

4個步驟:

  • 'pip install sendgrid'
  • 'pip install smtpapi'
  • 將sendgrid文件夾和smtpapi文件夾復制到您的GAE目錄中
  • 將smtpapi文件夾移到sendgrid文件夾中-來自github sendgrid-python的示例代碼現在可以正確執行,並且您具有GAE的sendgrid功能。

希望這對某人有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM