'Django-plolty-dash errors: for ImportError: Can't import 'Dash' from 'dash'

Python version: 3.7.9
Django version: 3.1.1
django_plotly_dash: 1.4.2

I have tried to install django_plotly_dash package after I tested the Django project could work properly. That is to say, the development server works fine and the webpage can be opened without problems. However, after I install the django_plotly_dash package and add the following to the project settings:

INSTALLED_APPS = [
    ...
    'django_plotly_dash.apps.DjangoPlotlyDashConfig',
    ...
    ]

Immediately, I had an error

ImportError: cannot import name 'Dash' from 'dash' (project\app\__init__.py)


Solution 1:[1]

I had the same problem but have now solved it.

What you should do is go to your urls.py file (the one that sits in the app you created) and add the following line:

from [FOLDER/S].[FOLDER/S].[NAME OF .PY FILE] import app

The [FOLDER/S] because you're leading it to the location of your py file where your Django/Plotly sits, and the import app because in your Django/Plotly py file you are creating app = DjangoDash([name in str])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nizarhamood