当我尝试将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
所以我不知道出了什么问题?我的熊猫怎么了?
修改
$ 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
这可能是问题吗?
答案 0 :(得分:11)
从当前工作目录中删除(或重命名)文件matplotlib.py
。它会使用相同的名称隐藏真实的库。
答案 1 :(得分:0)
我有一个简单的解决方案,请在您的项目字典中删除<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
<input type="text">
和__init__.pyc
文件。因为我也遇到了问题,所以使用此方法可以很好地解决它。