Pap*_*apu 2 python plotly-dash dash-bootstrap-components
我的仪表板工作正常。我已经安装了 dash_bootstrap_components 来为我的仪表板提供样式。
我写了pip install dash-bootstrap-components并且完美安装。
但是当我运行该应用程序时,出现此错误:
import dash_bootstrap_components as dbc
Run Code Online (Sandbox Code Playgroud)
ModuleNotFoundError: 没有名为“dash_bootstrap_components”的模块
我有:dash-1.8.0 dash-bootstrap-components-0.8.2
小智 5
我遇到了同样的问题,我尝试按照他们网站上的说明进行安装:https : //dash-bootstrap-components.opensource.faculty.ai/docs/quickstart/
在终端命令行中,我输入了以下内容:
pip install dash-bootstrap-components
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
由于环境错误,无法安装软件包:[Errno 13] 权限被拒绝:考虑使用 --user 选项或检查权限。
要解决它,您可以执行以下操作(第一个对我有用):
1)安装包到用户文件夹:
python -m pip install --user dash-bootstrap-components
Run Code Online (Sandbox Code Playgroud)
2)设置一个虚拟环境来安装包:
python3 -m venv env
source ./env/bin/activate
python -m pip install dash-bootstrap-components
Run Code Online (Sandbox Code Playgroud)
3)使用sudo安装到系统文件夹(不推荐):
sudo python -m pip install dash-bootstrap-components
Run Code Online (Sandbox Code Playgroud)
这样做后它应该可以工作,您可以使用以下代码创建一个文件并运行服务器以查看它是否有效:
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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4856 次 |
| 最近记录: |