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
193k20 gold badges145 silver badges276 bronze badges
asked May 27, 2017 at 19:24
8
  • 1
    install numpy first. Commented May 27, 2017 at 19:27
  • I did, and receive this: Requirement already satisfied: numpy in /usr/local/lib/python2.7/site-packages. Then why I try it again, I get the same error. Commented May 27, 2017 at 19:27
  • 1
    I think numpy version is not compatible with pandas. Commented May 27, 2017 at 19:28
  • Can you import numpy? If so, then your pandas is broken Commented May 27, 2017 at 19:30
  • When I try to, I get this: Commented May 27, 2017 at 19:30

4 Answers 4

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.

answered May 27, 2017 at 19:33
Sign up to request clarification or add additional context in comments.

Comments

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.

answered May 27, 2017 at 19:35

1 Comment

Yup I wasn't using anaconda but now it works. Thank you!
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!

answered Sep 27, 2017 at 11:46

Comments

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!
answered Jun 6, 2019 at 9:18

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.