jupyter notebook中显示pyecharts空白,记录

#tips:解决看结尾(1)(2)(3)

版本    

        1.jupyter使用pip isntall jupyter,可以看到版本 8.6.2 ,6.6.3, 5.7.2 , 4.2.2等,尤其是注意到有jupyterLAB。 

jupyter                           1.0.0
jupyter_client                    8.6.2
jupyter-console                   6.6.3
jupyter_contrib_core              0.4.2
jupyter_contrib_nbextensions      0.7.0
jupyter_core                      5.7.2
jupyter-echarts-pypkg             0.1.2
jupyter-events                    0.10.0
jupyter-highlight-selected-word   0.2.0
jupyter-lsp                       2.2.5
jupyter_nbextensions_configurator 0.6.4
jupyter_server                    2.14.1
jupyter_server_terminals          0.5.3
jupyterlab                        4.2.2
jupyterlab_pygments               0.3.0
jupyterlab_server                 2.27.2
jupyterlab_widgets                3.0.11
        2.pyecharts分0.5,v1,v2。目前最新为2.0.6

        实际上就是出现了版本“不兼容”

解决-官网

        Notebook - pyecharts - A Python Echarts Plotting Library built with love.

        1.资源引用

                看F12控制台,每次运行cell就会报错,而且指向了一个网址,怀疑是网络问题,然后依据“资源引用”,使用localhost server,notebook server。分别出现了无应答,找不到命令等。。。最终放弃两个方法

        2.进阶话题,notebook中,直接用,明显不行。

                使用jupyterLAB  两点注意中提到

                (1)在顶部声明 Notebook 类型,必须在引入 pyecharts.charts 等模块前声明

from pyecharts.globals import CurrentConfig, NotebookType
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB

                (2)需要使用load_javascript(),且可能需要多次使用,且需要分开使用load和render

from pyecharts.charts import Bar
bar = Bar()
bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])
bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])
bar.load_javascript()

                        然后新cell里写:render_notebook

bar.render_notebook()

你可能感兴趣的:(笔记,jupyter,python,人工智能,echarts)