Python 属性错误:';FrozenImporter';对象没有属性';文件名';

Python 属性错误:';FrozenImporter';对象没有属性';文件名';,python,pyinstaller,plotly-dash,Python,Pyinstaller,Plotly Dash,在使用PyInstaller运行由plotly破折号代码生成的exe文件时,我一直遇到以下错误 AttributeError: 'FrozenImporter' object has no attribute 'filename' 进行了一些深入检查,仅能够识别dash尝试导入dash_渲染器时发生的属性错误,并从行包中检索文件名。文件名 尝试添加以下内容,但仍无法解决 将导入破折号渲染器添加到我的代码中 已将dash和dash_渲染器包文件夹复制到dist/{app}/文件夹中 我的阴谋破折

在使用PyInstaller运行由plotly破折号代码生成的exe文件时,我一直遇到以下错误

AttributeError: 'FrozenImporter' object has no attribute 'filename'
进行了一些深入检查,仅能够识别dash尝试导入dash_渲染器时发生的属性错误,并从行包中检索文件名。文件名

尝试添加以下内容,但仍无法解决

  • 将导入破折号渲染器添加到我的代码中
  • 已将dash和dash_渲染器包文件夹复制到dist/{app}/文件夹中
  • 我的阴谋破折号代码

    external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
    
    app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
    
    app.layout = html.Div(children=[
        html.H2(children='H-{} Meeting Dashboard'.format("SS"), style={'text-align':'center'}),
        html.Div(children=[
            html.Div('''Generated on {}'''.format(str(datetime.now())[:19]), style={'text-align':'center', 'font-size':'15px'})
            ], className='row')]
        )
    
    if __name__ == "__main__":
        app.run_server(debug=True)
    
    用于生成exe文件的PyInstaller代码

    \path\to\python37\python.exe -m PyInstaller app_short.py
    
    运行.exe文件时出错,在下面遇到错误

    my\directory>app_short.exe
    2019-06-25 23:36:55 Imported all modules
    Traceback (most recent call last):
      File "app_short.py", line 24, in <module>
      File "site-packages\dash\dash.py", line 1476, in run_server
      File "site-packages\dash\dash.py", line 1361, in enable_dev_tools
      File "site-packages\dash\dash.py", line 1359, in <listcomp>
    AttributeError: 'FrozenImporter' object has no attribute 'filename'
    [16716] Failed to execute script app_short
    

    如何修复此错误?

    我遇到了相同的错误消息,我通过更改

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


    不确定为什么会发生这种情况,或者是否可以根据您的需要运行
    debug=False
    !也许其他人可以详细说明?

    显然,在pyinstaller编译过程中,dash所需的文件夹被遗漏了。通过将以下文件夹添加到后期编译中,可以完成此任务。dash_core_组件、dash_html_组件和dash_渲染器我刚刚看到了这个页面,并在我的代码中实现了您的“错误”解决方案。工作很有魅力,谢谢!但是您不能使用调试模式。对。它在debug=False时运行良好。太好了:)
    if __name__ == "__main__":
        app.run_server(debug=True)
    
    if __name__ == "__main__":
        app.run_server(debug=False)