【问题标题】:dash_bootstrap_components installed succesfully but no recogniseddash_bootstrap_components 安装成功但无法识别
【发布时间】:2020-05-18 04:31:21
【问题描述】:

我的仪表板运行良好。我已经安装了 dash_bootstrap_components 来为我的 dash 赋予风格。

我写了pip install dash-bootstrap-components 并完美安装。

但是当我运行应用程序时,我有这个错误:

import dash_bootstrap_components as dbc

ModuleNotFoundError: 没有名为“dash_bootstrap_components”的模块

我有: 破折号-1.8.0 dash-bootstrap-components-0.8.2

【问题讨论】:

    标签: python plotly-dash dash-bootstrap-components


    【解决方案1】:

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

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

    pip install dash-bootstrap-components
    

    我收到以下错误:

    由于 EnvironmentError 无法安装软件包:[Errno 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)
    
    
    
    

    【讨论】:

      猜你喜欢
      • 2012-04-25
      • 1970-01-01
      • 2020-09-14
      • 2020-06-11
      • 1970-01-01
      • 2021-11-19
      • 2021-11-06
      • 2019-07-20
      • 2021-03-19
      相关资源
      最近更新 更多