当前位置: 代码迷 >> 综合 >> Python3.7 pyecharts安装成功但是导包出现 cannot import name ‘Bar‘ 错误信息
  详细解决方案

Python3.7 pyecharts安装成功但是导包出现 cannot import name ‘Bar‘ 错误信息

热度:75   发布时间:2024-01-30 06:33:25.0

导入包时

from pyecharts.charts import Bar

Bar 出现错误,但明明是安装了 就是无法导入

from pyecharts import BarImportError: cannot import name 'Bar' from 'pyechats ..........路径

网上解决办法其一

下面是解决办法
打开 pycharm 自带的 Terminal输入命令:pip3 install wheel
然后在输入:pip3 install pyecharts==0.1.9.4

但不幸的是这个办法对我没有什么效果,我查了很久,还是没什么发现,后来我去目录看了下,发现/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

结果就好了 ,解决了就真的爽。

  相关解决方案