Jupyter notebook无法显示pyecharts 图形界面 ----解决方法

本人因昨天在Jupyter notebook 上运行了pyecharts ,但今早发现,图形界面无法显示了

在这里插入图片描述
解决方法如下:
下文采用官方说明-----------资源引用
步骤1:
在本地终端输入

git clone https://github.com/pyecharts/pyecharts-assets.git

步骤二:

python3 -m http.server

之后会出现 (不需要输入)
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) …

这样就好了,上述方法是针对Localhost-Server

如果是针对Notebook-Server

 # 1、获取 pyecharts-assets 项目
 git clone https://github.com/pyecharts/pyecharts-assets.git
 # 2、安装扩展插件
 cd pyecharts-assets
 # 安装并激活插件
 jupyter nbextension install assets
 jupyter nbextension enable assets/main
 # 3、配置 pyecharts 全局 HOST
  # 只需要在顶部声明 CurrentConfig.ONLINE_HOST 即可
 from pyecharts.globals import CurrentConfig, OnlineHostType

 # OnlineHostType.NOTEBOOK_HOST 默认值为 http://localhost:8888/nbextensions/assets/
 CurrentConfig.ONLINE_HOST = OnlineHostType.NOTEBOOK_HOST

 # 接下来所有图形的静态资源文件都会来自刚启动的服务器
 from pyecharts.charts import Bar
 bar = Bar()

如果步骤一样就可以和我一样得到相应的结果了
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45215649/article/details/107933750
今日推荐