Pandas Missing required dependencies ['numpy']
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.
source to share
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.
source to share
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.
source to share
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!
source to share