Skip to content

Setting Environment Variables

You can set environment variables to define the appropriate behavior for the live app on Plotly Cloud.

Environment variable being added

In the example above, the app might be written to behave differently depending on whether the app is running locally or elsewhere (the value of IS_LOCAL). With this environment variable set in Plotly Cloud, IS_LOCAL=false is added to the live app environment, where the app can retrieve it with os.environ.get() and execute the appropriate code.

Environment variables that you set for your app are applied at runtime.

Adding environment variables

Environment variable names have a maximum character length of 255 and are automatically turned into uppercase. If your environment variables names contain more than one word and you want to separate them, be sure to use underscores. Spaces are not supported.

To add an environment variable:

  1. Go to your app Settings Plotly Cloud app Settings icon.
  2. Go to the General tab.
  3. In Environment variables, select Edit Plotly Cloud Edit Settings icon.
  4. Select Add variable.
  5. Enter a name and value for your environment variable. Environment variables are case sensitive, so references in the app code need to match exactly what you enter.
  6. Select Save and restart. A new revision is created with the applied change.

Editing environment variables

You can change the names and values of environment variables after you've added them.

To edit an environment variable:

  1. Go to your app Settings Plotly Cloud app Settings icon.
  2. Go to the General tab.
  3. In Environment variables, select Edit Plotly Cloud Edit Settings icon.
  4. Edit the environment variable name and/or value. Environment variables are case sensitive, so references in the app code need to match exactly what you enter.
  5. Select Save and restart. A new revision is created with the applied change.

Deleting environment variables

To delete an environment variable:

  1. Go to your app Settings Plotly Cloud app Settings icon.
  2. Go to the General tab.
  3. In Environment variables, select Edit Plotly Cloud Edit Settings icon.
  4. Next to the environment variable that you want to delete, select Delete Plotly Cloud Delete Settings icon.
  5. Select Save and restart. A new revision is created with the applied change.