mac jupyter pyecharts顯示不了圖片,顯示空白


mac下安裝命令如下

pip install jupyter notebook

啟動

#啟動控制台
python -m IPython notebook

#如果有下面報錯
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 4: ordinal not in range(128)

#先執行下面環境變量后,再執行啟動即可
VBEARCHEN-MB0:~ vbeard$ export LANG="zn jupyter notebook"
VBEARCHEN-MB0:~ vbeard$ echo $LANG
zn jupyter notebook

驗證

輸入下面代碼驗證
from pyecharts import Bar
attr = ["襯衫", "羊毛衫", "雪紡衫", "褲子", "高跟鞋", "襪子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱狀圖數據堆疊示例")
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B1", attr, v2, is_stack=True)
bar

顯示空白圖如下:

分析日志發現:


#根據下面警告信息來看,是沒有獲取到echarts插件
[W 18:17:52.500 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200301181734 (127.0.0.1) 6.34ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python2
[I 18:17:53.496 NotebookApp] Adapting to protocol v5.1 for kernel 43be31cf-ab04-461d-a173-e28a5a889ea1
[W 18:17:53.982 NotebookApp] Replacing stale connection: 5446308d-0e4f-4292-80a5-891c993d096c:430379948fab4552b4efe99f377c9636
[I 18:19:20.675 NotebookApp] Saving file at /mydata/Untitled.ipynb
[I 18:19:52.775 NotebookApp] Saving file at /Untitled.ipynb
[W 18:21:26.958 NotebookApp] 404 GET /nbextensions/echarts/echarts.min.js?v=20200301181734 (127.0.0.1) 4.74ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python2


#解決方法
拷貝下面2個文件后顯示正常
cp /Users/chenwei/Library/Python/2.7/share/jupyter/nbextensions/echarts/echarts.min.js /usr/local/share/jupyter/nbextensions/echarts

cp /Users/chenwei/Library/Python/2.7/share/jupyter/nbextensions/jupyter-js-widgets/extension.js /usr/local/share/jupyter/nbextensions/widgets/notebook/js/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM