导入包时
from pyecharts.charts import Bar
Bar 出现错误,但明明是安装了 就是无法导入
from pyecharts import Bar
ImportError: cannot import name 'Bar' from 'pyechats ..........路径
网上解决办法其一
下面是解决办法
打开 pycharm 自带的 Terminal
先卸载之前的pyecharts
然后在输入:pip3 install pyecharts==1.7.0 (这个可以避免新版本的新属性)
如果速度太慢,建议使用其他源
比如 pip3 install -i https://pypi.doubanio.com/simple pyecharts==1.7.0
如果还是没用,建议去看看目录下的__init__.py文件
以下是我的问题:
但不幸的是这个办法对我没有什么效果,我查了很久,还是没什么发现,后来我去目录看了下,发现/pycharts/charts/init.py竟然是空的,随后我便复制了以下代码
# basic Charts
from ..charts.basic_charts.bar import Bar
from ..charts.basic_charts.bmap import BMap
from ..charts.basic_charts.boxplot import Boxplot
from ..charts.basic_charts.calendar import Calendar
from ..charts.basic_charts.effectscatter import EffectScatter
from ..charts.basic_charts.funnel import Funnel
from ..charts.basic_charts.gauge import Gauge
from ..charts.basic_charts.geo import Geo
from ..charts.basic_charts.graph import Graph
from ..charts.basic_charts.heatmap import HeatMap
from ..charts.basic_charts.kline import Kline
from ..charts.basic_charts.line import Line
from ..charts.basic_charts.liquid import Liquid
from ..charts.basic_charts.map import Map
from ..charts.basic_charts.parallel import Parallel
from ..charts.basic_charts.pictorialbar import PictorialBar
from ..charts.basic_charts.pie import Pie
from ..charts.basic_charts.polar import Polar
from ..charts.basic_charts.radar import Radar
from ..charts.basic_charts.sankey import Sankey
from ..charts.basic_charts.scatter import Scatter
from ..charts.basic_charts.sunburst import Sunburst
from ..charts.basic_charts.themeriver import ThemeRiver
from ..charts.basic_charts.tree import Tree
from ..charts.basic_charts.treemap import TreeMap
from ..charts.basic_charts.wordcloud import WordCloud
# Composite Charts
from ..charts.composite_charts.grid import Grid
from ..charts.composite_charts.page import Page
from ..charts.composite_charts.tab import Tab
from ..charts.composite_charts.timeline import Timeline
# 3d charts
from ..charts.three_axis_charts.bar3D import Bar3D
from ..charts.three_axis_charts.line3D import Line3D
from ..charts.three_axis_charts.map3D import Map3D
from ..charts.three_axis_charts.map_globe import MapGlobe
from ..charts.three_axis_charts.scatter3D import Scatter3D
from ..charts.three_axis_charts.surface3D import Surface3D
# alias
Candlestick = Kline
结果就好了 ,解决了就真的爽。