gpt4 book ai didi

python - Pandas :AttributeError: 'module' 对象没有属性 '__version__'

转载 作者:太空宇宙 更新时间:2023-11-03 12:27:19 26 4
gpt4 key购买 nike

当我尝试将 pandas 导入 Python 时出现此错误:

>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/__init__.py", line 44, in <module>
from pandas.core.api import *
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/api.py", line 9, in <module>
from pandas.core.groupby import Grouper
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/groupby.py", line 17, in <module>
from pandas.core.frame import DataFrame
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/frame.py", line 41, in <module>
from pandas.core.series import Series
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/series.py", line 2909, in <module>
import pandas.tools.plotting as _gfx
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/tools/plotting.py", line 135, in <module>
if _mpl_ge_1_5_0():
File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/tools/plotting.py", line 130, in _mpl_ge_1_5_0
return (matplotlib.__version__ >= LooseVersion('1.5')
AttributeError: 'module' object has no attribute '__version__'

但是当我检查是否安装了 pandas 时:

me$ conda install pandas
Fetching package metadata: ....
Solving package specifications: .....................
# All requested packages already installed.
# packages in environment at /Users/me/miniconda2:
#
pandas 0.17.1 np110py27_0

所以我不知道哪里出了问题?我的 Pandas 怎么了?

编辑

$ pip list |grep matplotlib
$ conda list matplotlib
# packages in environment at /Users/me/miniconda2:
#
matplotlib 1.5.0 np110py27_0

出于某种原因,pip list |grep matplotlib 没有输出

编辑2

我想看看可执行文件 ipythonpython 是否有不同的路径。所以我运行了这个:

$ python
>>> import sys
>>> print sys.executable
/Users/me/miniconda2/bin/python

但是在 IPython 中,我得到了这个:

$ ipython notebook
>>> import sys
>>> print sys.executable
/usr/local/opt/python/bin/python2.7

会不会是这个问题?

最佳答案

从当前工作目录中删除(或重命名)文件 matplotlib.py。它隐藏了同名的真实图书馆。

关于python - Pandas :AttributeError: 'module' 对象没有属性 '__version__',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34564249/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com