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

Dash-auth doesn't works

Hello!!

I’m working a database webapp for my own business and i have the heavy
work done: data tables, connection to cleardb mysql and deployment in
heroku but i don’t understand why when i try to go with de auth service,
dash-auth doesn’t works for me.

I’m trying this in the dash webapp:


import dash-auth

VALID_USERNAME_PASSWORD_PAIRS = {
‘my’: ‘keys’
}

app = dash.Dash(name, meta_tag, etc)

auth = dash_auth.BasicAuth(
app,
VALID_USERNAME_PASSWORD_PAIRS
)

etc.


I don’t understand the exception.

The exception is like this: ‘…cannot import requests’


Thanks for your time,

Cristian

Not an error I’ve seen… the implication is requests wasn’t installed, though it should been installed with dash_auth. Never mind that BasicAuth doesn’t need it, other things in the package do.

What versions of the dash packages do you have? pip list | grep dash
Can you paste in the full exception & stack trace?

Hi Alex,

The code is here:

dash==1.3.1
dash-auth==1.3.2

Traceback (most recent call last):
  File "C:/dev/projects/apps/basededatos-dash/basededatos-dash/setup.py", line 2, in <module>
    import dash_auth
  File "C:\Users\crist\Anaconda3\envs\basededatos\lib\site-packages\dash_auth\__init__.py", line 2, in <module>
    from .plotly_auth import PlotlyAuth  # noqa: F401
  File "C:\Users\crist\Anaconda3\envs\basededatos\lib\site-packages\dash_auth\plotly_auth.py", line 11, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Process finished with exit code 1

The complete setup.py code:

import dash
import dash_auth
import dash_html_components as html
import dash_bootstrap_components as dbc

from .templates.view import tablas, navbar

external_stylesheets = [dbc.themes.YETI]

VALID_USERNAME_PASSWORD_PAIRS = {
    'my': 'keys'
}

app = dash.Dash(__name__, external_stylesheets = external_stylesheets,
                meta_tags = [
                    {
                        'name': 'Aresformación',
                        'content': 'Base de datos'
                    },
                    {
                        'http-equiv': 'X-UA-Compatible',
                        'content': 'IE=edge'
                    },
                    {
                        'name': 'viewport',
                        'content': 'width=device-width, initial-scale=1'
                    }
                ])

auth = dash_auth.BasicAuth(
    app,
    VALID_USERNAME_PASSWORD_PAIRS
)

app.index_string = '''
<!DOCTYPE html>
<html>
    <head>
        {%metas%}
        <title>Aresformación</title>
        {%favicon%}
        {%css%}
    </head>
    <body>
        {%app_entry%}
        <footer>
            {%config%}
            {%scripts%}
            {%renderer%}
        </footer>
    </body>
</html>
'''


app.layout = html.Div([navbar, tablas])

server = app.server

if __name__ == '__main__':
    app.run_server(debug = True)

Ah, I just tried installing in a fresh venv and you’re right, you don’t get requests for some reason. Strange, I’ll have to look into this. Thanks for the report!

In the meantime, if you explicitly install requests and chart_studio (neither of which you need for BasicAuth, it’s just to make the rest of the package happy) you should be good to go.

Thanks Alex for your time

I had encountered a similar problem,
when installing dash_auth using pip in a virtualenvironment.

I have this error :

` error: invalid command ‘bdist_wheel’


Failed building wheel for dash-auth
Running setup.py clean for dash-auth
Failed to build dash-auth

`
I installed requests using pip , didn’t install chart_studio , seemed to work.

I worked my way to the browser and was prompted to sign in.
I input the credentials but the app asked me to sign in again.

Not too sure what may be the error here.