Solve the error problem of pyecharts in jupyter notebook
- 2021-06-29 11:24:44
- OfStack
It is recommended that you download the pyecharts (0.5.xx) version. If you install the V1 version by default using pip install pyecharts (for example, 1.7.1), the following error will occur:
1. Bar module import problem
from pyecharts import Bar
Report errors:
cannot import name'Bar'
Terms of settlement:
from pyecharts.charts import Bar
2. Bar usage error
from pyecharts import Bar
bar =Bar(" My first 1 Charts ", " Here is the subtitle ") # Title
bar.add(" clothing ", # Label
[" shirt ", " Cardigan ", " Chiffon shirt ", " trousers ", " High-heeled shoes ", " Socks "],#x coordinate
[5, 20, 36, 10, 75, 90]) #y coordinate
# is_more_utils = True # Show right toolbar
# bar.show_config() # Print all parameters
bar.render('my_first_chart.html')# Save Columns
bar
Report errors:
TypeError: init() takes from 1 to 2 positional arguments but 3 were given
Try commenting out the error line:
#bar =Bar ("My first chart", "Here is the subtitle")
There will be new errors:'Bar'object has no attribute'add'
Solution: Uninstall and install older versions
pip install pyecharts==0.5.10 -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
If an error occurs during installation (mac system):
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
Terms of settlement:
1. Install xcode
xcode-select --install
2. Then install pyecharts-0.5.10
3. Restart jupyter notebook after installation