Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: partially initialized module 'dash_html_components' has no attribute 'Div' (most likely due to a circular import) #1502

Closed
pantinashekhar opened this issue Dec 16, 2020 · 11 comments

Comments

@pantinashekhar
Copy link

pantinashekhar commented Dec 16, 2020

import dash_html_components as html 
app = Dash(__name__)
app.layout =html.Div(children=[html.H1(children='Hello Dash'),html.Div(children='''Dash: A web application framework for Python.'''),
                                dcc.Graph(id='example-graph', figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
                      }
                }
                )
               ])


if __name__ == '__main__':
    app.run_server(host='127.0.0.1',port='8050',debug=True)

Dash app is not working because of layout not being there but when I included then the error as shown in title comes.Please request you to help me at the earliest.

Regards
Chandrashekhar

@alexcjohnson
Copy link
Collaborator

This sounds similar to #1143 (which has been fixed in the dev branch but not yet released). What is the name of this file?

@pantinashekhar
Copy link
Author

pantinashekhar commented Dec 16, 2020 via email

@alexcjohnson
Copy link
Collaborator

yep, that would be it - you can't give your own script a name that matches any of the packages in your system, or when someone else (in this case dash_html_components) tries to do import dash they'll get your file rather than the installed package. Just change the name to something unique.

@pantinashekhar
Copy link
Author

pantinashekhar commented Dec 16, 2020 via email

@pantinashekhar
Copy link
Author

pantinashekhar commented Dec 16, 2020 via email

@alexcjohnson
Copy link
Collaborator

haha I wondered about that - you need from dash import Dash

@pantinashekhar
Copy link
Author

pantinashekhar commented Dec 16, 2020 via email

@pantinashekhar
Copy link
Author

pantinashekhar commented Dec 16, 2020 via email

@alexcjohnson
Copy link
Collaborator

Wow, line 1760... you have a lot of code in this file. I'd guess unmatched parentheses or something like that somewhere above this line, but I'd recommend getting an IDE with Python syntax checking, that should help you find the problem. The short code you posted first works fine for me once I add the two additional import statements (dash and dcc)

@pantinashekhar
Copy link
Author

pantinashekhar commented Dec 16, 2020 via email

@alexcjohnson
Copy link
Collaborator

Closing, as this issue won't lead to code changes in this repo. For further usage questions, a better forum may be https://community.plotly.com/c/dash/16

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants