0

问题描述

import ggplot时报错module 'pandas' has no attribute 'tslib'

问题出现的平台版本及自己尝试过哪些方法

win10 和 Mac OS
使用pip安装

相关代码

import ggplot


AttributeError Traceback (most recent call last)
<ipython-input-16-77748253ebb6> in <module>

  5 import calendar
  6 from pandas.plotting import register_matplotlib_converters

----> 7 import ggplot

  8 register_matplotlib_converters()

D:Anacondalibsite-packagesggplot__init__.py in <module>

 17 
 18 

---> 19 from .geoms import geom_area, geom_blank, geom_boxplot, geom_line, geom_point, geom_jitter, geom_histogram, geom_density, geom_hline, geom_vline, geom_bar, geom_abline, geom_tile, geom_rect, geom_bin2d, geom_step, geom_text, geom_path, geom_ribbon, geom_now_its_art, geom_violin, geom_errorbar, geom_polygon

 20 from .stats import stat_smooth, stat_density
 21 

D:Anacondalibsite-packagesggplotgeoms__init__.py in <module>
----> 1 from .geom_abline import geom_abline

  2 from .geom_area import geom_area
  3 from .geom_bar import geom_bar
  4 from .geom_bin2d import geom_bin2d
  5 from .geom_blank import geom_blank

D:Anacondalibsite-packagesggplotgeomsgeom_abline.py in <module>
----> 1 from .geom import geom

  2 
  3 class geom_abline(geom):
  4     """
  5     Line specified by slope and intercept

D:Anacondalibsite-packagesggplotgeomsgeom.py in <module>

  1 from __future__ import (absolute_import, division, print_function,
  2                         unicode_literals)

----> 3 from ..ggplot import ggplot

  4 from ..aes import aes
  5 

D:Anacondalibsite-packagesggplotggplot.py in <module>

 11 import warnings
 12 

---> 13 from .aes import aes

 14 from .legend import make_legend
 15 from .themes import theme_gray

D:Anacondalibsite-packagesggplotaes.py in <module>

  9 from patsy.eval import EvalEnvironment
 10 

---> 11 from . import utils

 12 
 13 import numpy as np

D:Anacondalibsite-packagesggplotutils.py in <module>

 79 
 80 date_types = (

---> 81 pd.tslib.Timestamp,

 82     pd.DatetimeIndex,
 83     pd.Period,

AttributeError: module 'pandas' has no attribute 'tslib'

你期待的结果是什么?实际看到的错误信息又是什么?

无报错

2019-03-16 提问
1 个回答
1

已采纳

抱歉, 看起来 ggplot(又称ggpy)是一个官方不再维护的项目了, github上的最近一次提交还是三年前. 参考:issue #654: Is this project dead.

AttributeError: module 'pandas' has no attribute 'tslib'也是已知的由于 pandas 版本更新, API 改变带来的 BUG. 参考: issue #617, issue #618. 针对这个问题已经有解决方案: PR #647: fixing incompatibility with pandas>=0.20.0, 但是恐怕作者短时间不会出来合并这个 PR.

貌似有该项目的 Fork: PR #656: Working copy of ggpy, 声称已经解决了这个BUG, 可以在这里看看.

github上很多库的错误往往可以通过阅读 issue 找到解决方案.

撰写答案

推广链接