【问题标题】:ImportError: No module named sendgrid local development server windows 10ImportError:没有名为 sendgrid 本地开发服务器 windows 10 的模块
【发布时间】:2016-06-13 11:03:35
【问题描述】:

这是我的代码:

import sendgrid
from sendgrid import SendGridClient, Mail
import Message

s = sendgrid.SendGridClient("2HXwPrNlQX-5RBJ61webMA")
message = sendgrid.Mail()

message.add_to('Jhon Doe <jdoe@test.com>')
message.set_subject('Example')
message.set_html('Body')
message.set_text('Body')
message.set_from('Jhon Doe <jdoe@test.com>')
status, msg = sg.send(message)
print(status, msg)

我正在安装 sendgrid

pip install -r requirements.txt

pip install sendgrid
pip install --upgrade sendgrid
pip install smtpapi
pip install --upgrade smtpapi
pip install python_http_client
pip install --upgrade python_http_client

当我运行应用程序时 dev_appserver.py ./ --port=8081

错误:ImportError:没有名为 sendgrid 的模块

【问题讨论】:

    标签: python google-app-engine sendgrid


    【解决方案1】:

    当您使用 GAE 时,使用 pip 安装东西是没有意义的。它在沙箱中运行,不会查看安装在外面的东西。正如the docs 所示,如果您需要安装第三方应用程序,您需要将相关模块复制或符号链接到您的应用程序目录中。

    【讨论】:

      【解决方案2】:

      App Engine 上的 Python 应用

      您可以通过以下两种方式之一将第三方库添加到您的应用:请求库或安装库。

      您可以从下面给出的链接中获取参考安装库

      Reference Link

      【讨论】:

        【解决方案3】:

        App Engine 在沙盒中运行,因此如果您在全局范围内安装新库,您的应用将无法访问它们。这是因为 App Engine 不会上传您所有的本地库,只会上传您的应用程序库。

        您可能想考虑使用Darth Vendor 或类似的东西。您在应用程序中安装所需的库,然后将它们作为应用程序的一部分上传

        【讨论】:

          猜你喜欢
          • 2020-07-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-16
          • 1970-01-01
          • 1970-01-01
          • 2014-10-30
          相关资源
          最近更新 更多