Python 3.7.3导入熊猫引发错误:ImportError:缺少必需的依赖项['numpy']

时间:2019-04-27 08:02:45

标签: python python-3.x pandas python-2.7 numpy

Ubuntu 18.04 LTS上,我确实有Python 2.7.15rc1Python 3.6.7Python 3.7.3。当我尝试使用import padas时,它可以与Python 2.7.15rc1Python 3.6.7一起正常工作,但是与Python 3.7.3一起使用时,它会引发以下错误:

ImportError: Missing required dependencies ['numpy']

我还使用以下命令升级numpy和pandas

sudo pip3 install --upgrade numpy
sudo pip3 install --upgrade pandas

但是出现相同的错误。请提供任何提示。

已编辑

  1. 我想问题出在numpy上,当我尝试导入numpy时会引发以下错误:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
ImportError: cannot import name 'multiarray' from 'numpy.core' (/usr/lib/python3/dist-packages/numpy/core/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: cannot import name 'multiarray' from 'numpy.core' (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
  1. 卸载Python 3.6.7是否安全?

2 个答案:

答案 0 :(得分:1)

您的pandas版本是什么?我的Mac和0.24.2版本的熊猫都安装了Python 3.7.3,import pandas的工作方式如下。

$ python3.7 -V
Python 3.7.3
$ python3.7
Python 3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> pandas.__version__
'0.24.2'

还可以在安装中尝试使用pip3.7而不是pip3

答案 1 :(得分:0)

我认为您也应该在项目中加入numpy
如果没有,请尝试以下命令:

pip3 uninstall pandas
pip3 uninstall numpy
pip3 install pandas
pip3 install numpy