3

enter image description here

I am currently following a beginners introduction to machine learning. While entering in the command: import pandas as pd in the python shell in terminal, I get an error reading:

ImportError: Missing required dependencies ['numpy'].

I already looked at the other similar question, tried that solution, but still received the same error.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
sdksmkfnajnf
  • 76
  • 1
  • 1
  • 10

4 Answers4

2

Looks like you might be running on a Mac and perhaps using the default system python. For whatever reason you don't have a complete installation. you have pandas but not numpy. I'm not sure which packages the tutorial you are following uses, but I would recommend installing the Anaconda python distribution as it includes pandas, all its dependencies and much more, including the scikit-learn package often used for machine learning.

If you want to know more about installing a Python environment for machine learning on a Mac, there is a good tutorial on machinelearningmastery.com.

2

This doesn't have anything to do with incompatibility. As @Peter mentioned, you simply don't have NumPy and should install through Anaconda. Here is the code within pandas that is giving you the error:

# Let users know if they're missing any of our hard dependencies
hard_dependencies = ("numpy", "pytz", "dateutil")
missing_dependencies = []

for dependency in hard_dependencies:
    try:
        __import__(dependency)
    except ImportError as e:
        missing_dependencies.append(dependency)

if missing_dependencies:
    raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
del hard_dependencies, dependency, missing_dependencies

Notice there is nothing here about version.

Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
0

I had a same problem. I don't know what is the cause of the problem, but it seems to deal with how numpy is installed. You can try the following:

  1. Install pandas
  2. Uninstall numpy
  3. Download numpy whl for your needs from here
  4. Install numpy from downloaded whl

That worked for me!

mrGreenBrown
  • 576
  • 1
  • 7
  • 20
0

I get the same error message with my Anaconda installation when I forget to activate the environment:

Testcode: import_pandas.py:

import pandas
print('Pandas import succeeded!')

Run import_pandas.py with ImportError:

Microsoft Windows [Version 10.0.16299.1146]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\peter\demo>python import_pandas.py
Traceback (most recent call last):
  File "import_pandas.py", line 1, in <module>
    import pandas
  File "C:\Users\peter\AppData\Local\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']

However, after activating conda everything works perfectly fine:

C:\Users\peter\demo>activate
C:\Users\peter\demo>conda.bat activate

(base) C:\Users\peter\demo>python import_pandas.py
Pandas import succeeded!
Peter
  • 10,959
  • 2
  • 30
  • 47