1

I've been trying to install Plot.ly Python SDK, I have it included in the requirements.txt but still fails and I get a Page Not Found error when calling a page served by Flask.

1 Answer 1

1

The problem with Plot.ly is that it requires the credentials to be installed:

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

And this won't run in as a code, not from ssh in the console because the instance doesn't has access to the ~/.plotly/.credentials file, i.e. it can't create it nor access it, so any call to the API will always fail. In AWS logs you'll get the following error:

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)'.

So the solution is to call the plotly.plotly.sign_in() method that it's not even mentioned in their getting started guide nor the API reference, and it must be called with following arguments:

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

That I implemented by having those values as EB Environment Properties:

plotly.plotly.sign_in(os.environ['YOUR_PLOTLY_USERNAME_ENV_PROPERTY_NAME'],os.environ['YOUR_PLOTLY_API_KEY_ENV_PROPERTY_NAME'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.