1

I'm trying to install Scikit and run a python file that only has:

import sklearn

To check if Scikit works. This is the error I get:

Traceback (most recent call last): File "hello-world.py", line 1, in import sklearn File "/Library/Python/2.7/site-packages/sklearn/init.py", line 57, in from .base import clone File "/Library/Python/2.7/site-packages/sklearn/base.py", line 9, in from scipy import sparse ImportError: No module named scipy

I have been at this for hours now. My python version is Python 2.7.11

which -a python

gives me this:

/usr/local/bin/python
/usr/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/Users/Iliad/anaconda/bin/python

I had had Python 3.5 Installed before, but downloaded Anaconda for 2.7, but can't make sure it is set to work with that version.

Thanks!

1 Answer 1

4

I will start with

python --version

Just to be sure

and then in python repl. Use this

import site
site.getsitepackages()

This would give you something like :

['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']

Check in all the dist-packages for scipy. My guess is that it is not there. If you have any other "dist-packages" type of folder then you should add that to your PYTHONPATH.

Sign up to request clarification or add additional context in comments.

4 Comments

I get ['/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/site-python', '/Library/Python/2.7/site-packages'] back, but none of those directories have scipy inside of them. Also /Library/Frameworks/Python.framework/Versions/2.7/lib/site-python Does not exist! And the python version is Python 2.7.11
Also, although the Python.framework doesn't exist, the python IDE runs perfectly
Quick solution could be to do pip install sklearn. The other way (which I think you should do ) is to figure out 1. Where did anaconda install your dist-packaged (It;s usually under /User/<your name>/ anaconda/lib< ) and 2. Add /Users/Iliad/anaconda/bin/python in start of your path so that this python is picked up first. And finally 3.After you figure out where is the site-packages for anaconda add them to pythonpath.
Option 1 helped me out. Thank you so much, works perfectly now!

Your Answer

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.