3

I'm trying to run this Dash tutorial https://github.com/cryptopotluck/alpha_vantage_tutorial/tree/master/dash_bootstrap/

And after installing the requirements with pip install -r requirements.txt, and after all libraries are properly installed as PyCharm does not red underline anymore the now installed import libraries,

import dash
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import requests, base64
from io import BytesIO
import dash_core_components as dcc
import plotly.graph_objs as go
from collections import Counter

I always get this error:

 Traceback (most recent call last):
  File "dash.py", line 1, in <module>
    import dash
  File "dash.py", line 2, in <module>
    import dash_bootstrap_components as dbc
  File "/Users/user/project/venv3.8/lib/python3.8/site-packages/dash_bootstrap_components/__init__.py", line 6, in <module>
    from . import _components
  File "/Users/user/project/venv3.8/lib/python3.8/site-packages/dash_bootstrap_components/_components/__init__.py", line 1, in <module>
    from .Alert import Alert
  File "/Users/user/project/venv3.8/lib/python3.8/site-packages/dash_bootstrap_components/_components/Alert.py", line 3, in <module>
    from dash.development.base_component import Component, _explicitize_args
ModuleNotFoundError: No module named 'dash.development'; 'dash' is not a package package

Even though Dash is already installed.

I tried a clean code, just with these two lines, same error:

  import dash
  import dash_bootstrap_components as dbc

I have changed the python versions in my virtual environment 3.6, 3.7, 3.8 and 3.9 and got the same error. I have uninstalled and installed the libraries again, the Dash library, the dash_bootstrap_components library, the dash-core-components, Plotly, etc, and same thing.

I also installed different versions of Dash and some of the other libraries. Nothing.

What could possibly be the cause other than the obvious reason that the dash.development module does not exist. Am I missing something?

3 Answers 3

9

I have landed on this page after getting a similar error (see below). I had named my app file dash.py, which of course causes a conflict for import. Renaming the app file fixed the problem.

site-packages/dash_core_components/__init__.py", line 1, in <module>
    from dash.dcc import *  # noqa: F401, F403, E402
ModuleNotFoundError: No module named 'dash.dcc'; 'dash' is not a package
Sign up to request clarification or add additional context in comments.

Comments

2

You may not have the latest version of dash. No guarantee it won't break your tutorial but try these:

pip install --upgrade dash dash-core-components dash-html-components dash-renderer

For Conda:

conda install dash dash-core-components dash-html-components dash-renderer -c conda-forge

Comments

1

There is no issue with your code or installation. It should work fine if you rename your file from dash.py to <any other name>.py (eg: test.py). This happens because the library you are importing and your local file name is of the same name.

Comments