为什么pip show告诉我我有numpy版本1.13.1,而Pandas认为我有numpy版本1.8.0rc1

时间:2017-12-26 21:01:44

标签: python pandas numpy

为什么pip show告诉我我有numpy版本1.13.1,而Pandas认为我有numpy版本1.8.0rc1

导入pandas时出现以下错误。有人能告诉我如何解决这个问题。

  1. 导入pandas

     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 23, in <module>
         from pandas.compat.numpy import *
       File "/Library/Python/2.7/site-packages/pandas/compat/numpy/__init__.py", line 24, in <module>
         'this pandas version'.format(_np_version))
     ImportError: this version of pandas is incompatible with numpy < 1.9.0
     your numpy version is 1.8.0rc1.
     Please upgrade numpy to >= 1.9.0 to use this pandas version
    
  2. 这些是我机器上numpy的详细信息

     pip show numpy 
     Name: numpy
     Version: 1.13.3
     Summary: NumPy: array processing for numbers, strings, records, and objects.
     Home-page: http://www.numpy.org
     Author: NumPy Developers
     Author-email: numpy-discussion@python.org
     License: BSD
     Location: /Library/Python/2.7/site-packages
    
  3. 这些是我机器上的大熊猫的详细信息

     Name: pandas
     Version: 0.21.1
     Summary: Powerful data structures for data analysis, time series,and statistics
     Home-page: http://pandas.pydata.org
     Author: The PyData Development Team
     Author-email: pydata@googlegroups.com
     License: BSD
     Location: /Library/Python/2.7/site-packages
     Requires: pytz, python-dateutil, numpy
    
  4. 我尝试过卸载&amp;重新安装numpy

     sudo  pip uninstall numpy
     sudo  pip install numpy  
    
  5. 如果有任何依赖性问题,我已检查过pandas

     pip check pandas         
     No broken requirements found.
    
  6. 我尝试取消链接和重新连接numpy

     brew unlink numpy        
     brew link numpy
    
     Linking /usr/local/Cellar/numpy/1.13.3... 
     Error: Could not symlink bin/f2py
     Target /usr/local/bin/f2py
     already exists. You may want to remove it:
       rm '/usr/local/bin/f2py'
    
     To force the link and overwrite all conflicting files:
       brew link --overwrite numpy
    
     To list all files that would be deleted:
       brew link --overwrite --dry-run numpy
    

1 个答案:

答案 0 :(得分:0)

在python REPL中(我使用ipython)

template<typename Mixin, typename Ctor>
struct EntityFactory : Mixin, Entity
{
    EntityFactory() = Ctor;
    void preUpdate(float dt)
    {Mixin::mixinPreUpdate(dt);}
    void update(float dt)
    {Mixin::mixinUpdate(dt);}
    void lateUpdate(float dt)
    {Mixin::mixinLateUpdate(dt);}
 };

这将显示numpy来自哪里,而pandas则会这样做

In [98]: import numpy as np

In [99]: np.__version__
Out[99]: '1.13.3'

In [100]: np.__file__
Out[100]: '/Users//anaconda/lib/python2.7/site-packages/numpy/__init__.pyc'
终端窗口中的

输入In [103]: import pandas as pd In [104]: pd.__version__ Out[104]: u'0.20.3' In [105]: pd.__file__ Out[105]: '/Users//anaconda/lib/python2.7/site-packages/pandas/__init__.pyc'