Ad

Python 3.7.3 Import Pandas Throws Error: ImportError: Missing Required Dependencies ['numpy']

On Ubuntu 18.04 LTS, I do have Python 2.7.15rc1, Python 3.6.7 and Python 3.7.3. When I try to import padas, it works fine with Python 2.7.15rc1 and Python 3.6.7 but with Python 3.7.3 it throws the following error:

ImportError: Missing required dependencies ['numpy']

I also upgrade numpy and pandas using the following commands

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

But getting the same error. Any hints, please.

Edited

  1. I guess the problem is with numpy, when I tried import numpy it throws the following error:
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. Is it safe to uninstall Python 3.6.7?
Ad

Answer

What is your pandas version? I have Python 3.7.3 on my Mac and 0.24.2 version of pandas, and import pandas works as below.

$ 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'

Also try pip3.7 in your installation instead of pip3

Ad
source: stackoverflow.com
Ad