Python:没有名为“dash.development”的模块。 “dash”不是一个包

2024-02-16

我正在尝试运行这个 Dash 教程https://github.com/cryptopotluck/alpha_vantage_tutorial/tree/master/dash_bootstrap/ https://github.com/cryptopotluck/alpha_vantage_tutorial/tree/master/dash_bootstrap/

在使用 pip install -rrequirements.txt 安装需求之后,并且在正确安装所有库之后,因为 PyCharm 不再用红色下划线显示现在安装的导入库,

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

我总是收到这个错误:

 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

即使 Dash 已经安装。

我尝试了一个干净的代码,只有这两行,同样的错误:

  import dash
  import dash_bootstrap_components as dbc

我已经更改了虚拟环境 3.6、3.7、3.8 和 3.9 中的 python 版本,并得到了相同的错误。我已经卸载并再次安装了这些库,Dash 库、dash_bootstrap_components 库、dash-core-components、Plotly 等,以及同样的东西。

我还安装了不同版本的 Dash 和其他一些库。没有什么。

除了 dash.development 模块不存在的明显原因之外,可能还有什么原因。我错过了什么吗?


在收到类似的错误后我已经登陆此页面(见下文)。我已将应用程序文件命名为 dash.py,这当然会导致导入冲突。重命名应用程序文件解决了该问题。

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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Python:没有名为“dash.development”的模块。 “dash”不是一个包 的相关文章

随机推荐