当我尝试将pandas导入Python时,我收到此错误:
>>> import pandas Traceback (most recent call last): File "", line 1, in File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/__init__.py", line 44, in from pandas.core.api import * File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/api.py", line 9, in from pandas.core.groupby import Grouper File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/groupby.py", line 17, in from pandas.core.frame import DataFrame File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/frame.py", line 41, in from pandas.core.series import Series File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/core/series.py", line 2909, in import pandas.tools.plotting as _gfx File "/Users/robertdefilippi/miniconda2/lib/python2.7/site-packages/pandas/tools/plotting.py", line 135, in 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
所以我不知道出了什么问题?我的熊猫怎么了?
编辑
$ pip list |grep matplotlib $ conda list matplotlib # packages in environment at /Users/me/miniconda2: # matplotlib 1.5.0 np110py27_0
出于某种原因,没有输出 pip list |grep matplotlib
EDIT2
我想看看是否有不同的路径的可执行文件ipython
和python
.所以我跑了这个:
$ 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
从当前工作目录中删除(或重命名)该文件.它以相同的名称遮蔽真实的库.