美文网首页
[python 3.7] [Dash] [SyntaxError

[python 3.7] [Dash] [SyntaxError

作者: 荷包蛋酱 | 来源:发表于2018-08-09 10:38 被阅读0次

    来来来这是一个很新的错,连作者们都是12小时之前才fix的

    Traceback (most recent call last):
      File "D:/xx/xx.py", line 4, in <module>
        import dash_html_components as html
      File "C:\Users\lenovo\AppData\Roaming\Python\Python37\site-packages\dash_html_components\__init__.py", line 20, in <module>
        'dash_html_components'
      File "C:\Users\lenovo\AppData\Roaming\Python\Python37\site-packages\dash\development\component_loader.py", line 51, in load_components
        namespace
      File "C:\Users\lenovo\AppData\Roaming\Python\Python37\site-packages\dash\development\base_component.py", line 443, in generate_class
        exec(string, scope)
      File "<string>", line 44
        def __init__(self, children=None, id=Component.UNDEFINED, n_clicks=Component.UNDEFINED, n_clicks_timestamp=Component.UNDEFINED, key=Component.UNDEFINED, role=Component.UNDEFINED, async=Component.UNDEFINED, charSet=Component.UNDEFINED, crossOrigin=Component.UNDEFINED, defer=Component.UNDEFINED, integrity=Component.UNDEFINED, src=Component.UNDEFINED, type=Component.UNDEFINED, accessKey=Component.UNDEFINED, className=Component.UNDEFINED, contentEditable=Component.UNDEFINED, contextMenu=Component.UNDEFINED, dir=Component.UNDEFINED, draggable=Component.UNDEFINED, hidden=Component.UNDEFINED, lang=Component.UNDEFINED, spellCheck=Component.UNDEFINED, style=Component.UNDEFINED, tabIndex=Component.UNDEFINED, title=Component.UNDEFINED, **kwargs):
                                                                                                                                                                                               ^
    SyntaxError: invalid syntax
    
    

    问题的详细讨论参见:
    https://community.plot.ly/t/error-running-dash-after-upgrade-of-plotly/12507

    发生问题的原因就是,python 3.7 中新增了keywords: async 和 await ,所以有一些包用这两个作为arguments名字的,就GG了

    image.png

    解决办法也很好办,大佬已经说fix方法了,在代码里加入这两行
    https://github.com/plotly/dash/pull/325/commits/3aea0fbe1af8002b2f3c58621a548459bae909e9

    image.png

    相关文章

      网友评论

          本文标题:[python 3.7] [Dash] [SyntaxError

          本文链接:https://www.haomeiwen.com/subject/dcdqbftx.html