motam79
motam79

Reputation: 3824

In Anaconda, I can not load packages with python, but ipython works

I have installed my python using Anaconda, and I have been installing packages with both pip install and conda install. I have also installed the machine learning library: sklearn. I was trying to run the following code:

import sys
print sys.version
from sklearn.gaussian_process import kernels

Where I run it with python I get an import error:

2.7.11 |Anaconda 4.0.0 (x86_64)| (default, Dec  6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)]
Traceback (most recent call last):
  File "temp1.py", line 4, in <module>
    from sklearn.gaussian_process import kernels
ImportError: cannot import name kernels

However, when I run it with ipython, there is no error:

2.7.12 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]
sklearn.gaussian_process.kernels
/Users/my_name/anaconda/lib/python2.7/site-packages/sklearn/gaussian_process/kernels.pyc

I noticed the ipython's version is "Anaconda custom" what does it mean? Why the python's version is Anaconda 4.0.0 instead of Anaconda custom? I suspect that is the reason it can not load all installed modules.

The location of the python and ipython binaries:

/Users/my_name/anaconda/bin/python
/Users/my_name/anaconda/bin/ipython

Upvotes: 0

Views: 630

Answers (1)

simon
simon

Reputation: 2821

You have two versions of anaconda and two versions of python. Try deleting the unwanted anaconda folder.

You can also type in a console "which python" on linux or "where python" on windows. This will tell you the location of the file it will execute.

Upvotes: 1

Related Questions