Pandas Missing required dependencies ['numpy']

enter image description here

I am currently following a beginner's introduction to machine learning. When I enter the command: import pandas as pd

in the python shell in the terminal, I get the error:

ImportError: missing required dependencies ['numpy'].

I have already looked at another similar question, tried this solution but still got the same error.

+3


source to share


4 answers


It looks like you can work on a Mac and maybe use the system default python. For some reason, you don't have a complete installation. you have pandas

but not numpy

. I'm not sure which packages the tutorial you are using, but I would recommend installing the Anaconda python distribution as it includes pandas

, all its dependencies, and more, including a package scikit-learn

that is often used for machine learning.



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

+2


source


This has nothing to do with incompatibility. As @Peter pointed out, you just don't have NumPy and have to install it via Anaconda. Here is the code inside pandas that gives 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

      



Note that there is nothing about the version here.

+2


source


I had the same problem. I don't know what is the cause of the problem, but it seems to be about how numpy is installed. You can try this:

  • Install pandas
  • Remove numpy
  • Download numpy whl for your needs here
  • Install numpy from downloaded whl

It worked for me!

0


source


When I forget to activate the environment, I get the same error when installing Anaconda:

Test code: 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 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!

      

0


source







All Articles