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

Dash Plotly not compatible with IIS

Error occurred : Traceback (most recent call last): File “E:\IndustryDashboard\wfastcgi.py”, line 794, in main env, handler = read_wsgi_handler(response.physical_path) File “E:\IndustryDashboard\wfastcgi.py”, line 636, in read_wsgi_handler handler = get_wsgi_handler(os.getenv(“WSGI_HANDLER”)) File “E:\IndustryDashboard\wfastcgi.py”, line 603, in get_wsgi_handler handler = import(module_name, fromlist=[name_list[0][0]]) File “.\Analyst_app.py”, line 9, in plotly.tools.set_credentials_file(username=‘Indospirit’, api_key=‘xXEe2QiGUZPXMbglNZko’) File “C:\Python\Python37-32\lib\site-packages\plotly\tools.py”, line 128, in set_credentials_file raise exceptions.PlotlyError("You don’t have proper file permissions " plotly.exceptions.PlotlyError: You don’t have proper file permissions to run this function. StdOut: StdErr: C:\Python\Python37-32\lib\site-packages\plotly\tools.py:102: UserWarning: 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)’. Questions? Visit https://support.plot.ly

WSGI is unable to acces plotly files as required thus, the whole app falls apart.

Instead of using the credentials files, which the IIS user doesn’t have access, can you try putting your keys in environ vars ?

The env vars you need:

PLOTLY_USERNAME
PLOTLY_API_KEY

And maybe those if you need the .configs file.

PLOTLY_DOMAIN
PLOTLY_API_DOMAIN

Can you please give an example of where I can find the files to update these ENV variables?

The files are in ~/.plotly.

Thanks Phillippe, i dont see a place in the .config or .credential files for environ vars. Where am I supposed to update the ENV variables?

You don’t update them in a file, you have to set like so:

Linux:
$ export PLOTLY_USERNAME=my-username

Windows:

setx PLOTLY_USERNAME=my-username

Python:

import os

os.environ['PLOTLY_USERNAME'] = 'my-username'

thanks Philippe.

My app.py file has the following

import dash

from dash.dependencies import Input, Output

import dash_core_components as dcc

import dash_html_components as html

import plotly.graph_objs as go

import pandas as pd

import os

import plotly

plotly.tools.set_credentials_file(username=“jabrown10”, api_key=“pFozcI42TMpXne3vGBoE”)

import plotly.plotly as py

py.sign_in(“jabrown10”, “jv281316N”)

os.environ[‘PLOTLY_USERNAME’] = ‘********’

os.environ[‘PLOTLY_API_KEY’] = ‘xxxxxxxxxxxxxxxxxx’

os.environ[‘PLOTLY_DOMAIN’] = ‘https://plot.ly

os.environ[‘PLOTLY_API_DOMAIN’] = ‘https://api.plot.ly

and I also set the above keys as Environment variables on my system but I continue to get the same error

Error occurred while reading WSGI handler:

Traceback (most recent call last):
File “C:\inetpub\wwwroot\myapp\app\wfastcgi.py”, line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File “C:\inetpub\wwwroot\myapp\app\wfastcgi.py”, line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv(“WSGI_HANDLER”))
File “C:\inetpub\wwwroot\myapp\app\wfastcgi.py”, line 600, in get_wsgi_handler
handler = import(module_name, fromlist=[name_list[0][0]])
File “C:\inetpub\wwwroot\myapp\app\index.py”, line 20, in
plotly.tools.set_credentials_file(username="******", api_key=“xxxxxxxxxxxxxxx”)
File “C:\Python36\lib\site-packages\plotly\tools.py”, line 128, in set_credentials_file
raise exceptions.PlotlyError("You don’t have proper file permissions "
plotly.exceptions.PlotlyError: You don’t have proper file permissions to run this function.

StdOut:

StdErr: C:\Python36\lib\site-packages\plotly\tools.py:102: UserWarning:

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)’.
Questions? Visit https://support.plot.ly

You need to remove the plotly.tools.set_credentials_file(username=“xx”, api_key=“xx”), setting them on the system is the right way to do it and you can remove the os.environ part if you do.

Thanks That did the trick!