ModuleNotFoundError: No module named 'dash.dash_table'

ModuleNotFoundError: No module named 'dash.dash_table'

我正在尝试 运行 像这样的简单代码:

import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict('records'),
)

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

但是得到这个错误:

 Traceback (most recent call last):
  File "/Users/.../PycharmProjects/pythonProject1/main.py", line 2, in <module>
    import dash_table
  File "/Users/.../PycharmProjects/pythonProject1/venv/bin/py/lib/python3.8/site-packages/dash_table/__init__.py", line 1, in <module>
    from dash.dash_table import *  # noqa: F401, F403, E402
ModuleNotFoundError: No module named 'dash.dash_table'

请帮忙:(

P.S。我已经通过 pip 安装了 dash-table。没有帮助..

您的 dash 和 dash_table 版本似乎与最新版本的 Dash 不兼容,当您安装 dash 包时,它还会安装其他包,包括 dash_table。您能否卸载 dash_table 和 dash,重新安装 dash,看看它是否有效?