Black Lives Matter. Please consider donating to Black Girls Code today.

Cannot use the API Key

import plotly.plotly as py
import as tls
from plotly.graph_objs import *

tls.set_credentials_file(“myusername”, “my_API_Key”)
py.sign_in(“myusername”, “my_API_Key”)

PlotlyRequestError: Aw, snap! You tried to use our API as the user ‘myuserbame’, but the supplied API key doesn’t match our records. You can view your API key at

If you already have an username and you generated an API key, then delete the line
tls.set_credentials_file(“myusername”, “my_API_Key”) from your code.

In case you haven’t a Plotly account yet, read this answer to similar question:

I just realized that it works ONLY on the jupyter notebook on localhost. When I try the API on the jupyter notebook on the Virtual Machine hosted on Google Cloud Platform,it does not work and produce the error which I have listed above.