dash_bootstrap_components成功安装,但无法识别



我的破折号工作得很好。我已经安装了dash_bootstrap_components来为我的破折号提供风格。

我写了pip install dash-bootstrap-components,并且安装得很好。

但是当我运行该应用程序时,我遇到此错误:

import dash_bootstrap_components as dbc

ModuleNotFoundError: 没有名为"dash_bootstrap_components"的模块

我有: 达世币-1.8.0 破折号自举组件-0.8.2

我遇到了同样的问题,我尝试按照他们网站上的说明进行安装:https://dash-bootstrap-components.opensource.faculty.ai/docs/quickstart/

在终端命令行中,我键入了以下内容:

pip install dash-bootstrap-components

我收到以下错误:

由于环境错误,无法安装软件包: [错误 13] 权限被拒绝:请考虑使用 --user 选项或检查权限。

要解决它,您可以执行以下操作(第一个对我有用(:

1( 将软件包安装到用户文件夹:

python -m pip install --user dash-bootstrap-components

2( 设置虚拟环境以安装软件包:

python3 -m venv env
source ./env/bin/activate 
python -m pip install dash-bootstrap-components

3( 使用 sudo 安装到系统文件夹(不推荐(:

sudo python -m pip install dash-bootstrap-components

完成此操作后,您可以使用以下代码创建一个文件并运行服务器以查看它是否有效

import dash
import dash_bootstrap_components as dbc
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = dbc.Container(
dbc.Alert("Hello Bootstrap!", color="success"),
className="p-5",
)
if __name__ == "__main__":
app.run_server(debug=True)

最新更新