【问题标题】:How to use Plotly Python SDK in AWS Elastic Beanstalk如何在 AWS Elastic Beanstalk 中使用 Plotly Python 开发工具包
【发布时间】:2018-01-24 23:34:01
【问题描述】:

我一直在尝试安装 Plot.ly Python SDK,我已将其包含在 requirements.txt 中,但仍然失败,并且在调用 Flask 提供的页面时出现页面未找到错误。

【问题讨论】:

    标签: python amazon-web-services flask amazon-elastic-beanstalk plotly


    【解决方案1】:

    Plot.ly 的问题在于它需要安装凭据:

    import plotly 
    plotly.tools.set_credentials_file(username='SomeDemoAccount', api_key='SomeAPIKey')
    

    这不会作为代码运行,而不是从控制台中的 ssh 运行,因为实例无权访问 ~/.plotly/.credentials 文件,即它无法创建或访问它,因此任何调用API 总是会失败。在 AWS 日志中,您将收到以下错误:

    Looks like you don't have 'read-write' permission to your 'home' ('~') directory or to our '~/.plotly' directory. That means plotly's python api can't setup local configuration files. No problem though! You'll just have to sign-in using 'plotly.plotly.sign_in()'. For help with that: 'help(plotly.plotly.sign_in)'.
    

    所以解决方案是调用plotly.plotly.sign_in() 方法,他们的入门指南和 API 参考中甚至都没有提到它,并且必须使用以下参数调用它:

    plotly.plotly.sign_in("Your Plotly Username","Your Plotly API Key")
    

    我通过将这些值作为 EB 环境属性来实现:

    plotly.plotly.sign_in(os.environ['YOUR_PLOTLY_USERNAME_ENV_PROPERTY_NAME'],os.environ['YOUR_PLOTLY_API_KEY_ENV_PROPERTY_NAME'])
    

    【讨论】:

      猜你喜欢
      • 2013-09-29
      • 1970-01-01
      • 2017-02-15
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 2021-03-07
      • 2017-05-14
      • 2017-10-20
      相关资源
      最近更新 更多