脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - 解决pyecharts在jupyter notebook中使用报错问题

解决pyecharts在jupyter notebook中使用报错问题

2021-07-17 00:35LatinoCaribo Python

这篇文章主要介绍了解决pyecharts在jupyter notebook中使用报错问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

建议下载pyecharts(0.5.xx)版本,如果使用 pip install pyecharts 默认安装V1版本(如1.7.1)会出现如下报错:

1、Bar模块导入问题

from pyecharts import Bar

报错:

cannot import name ‘Bar'

解决办法:

from pyecharts.charts import Bar

2、Bar 使用报错

?
1
2
3
4
5
6
7
8
9
from pyecharts import Bar
bar =Bar("我的第一个图表", "这里是副标题") #标题
bar.add("服装", #标签
  ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],#x坐标
  [5, 20, 36, 10, 75, 90]) #y坐标
# is_more_utils = True #显示右侧的工具栏
# bar.show_config() # 打印所有参数
bar.render('my_first_chart.html')#保存图列
bar

报错:

TypeError: init() takes from 1 to 2 positional arguments but 3 were given

尝试注释掉报错行:

#bar =Bar("我的第一个图表", "这里是副标题")

还会有新的报错:‘Bar' object has no attribute ‘add'

解决办法:卸载、安装旧版本

pip install pyecharts==0.5.10 -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

如果安装时报错(mac系统):

Failed building wheel for dukpy
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1

解决办法:

1、安装xcode

xcode-select --install

2、然后再安装pyecharts-0.5.10

3、安装成果后重启jupyter notebook即可

以上这篇解决pyecharts在jupyter notebook中使用报错问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/weixin_43337509/article/details/105273102

延伸 · 阅读

精彩推荐