Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: modul not found after Anaconda installation

I've successfully installed Python 2.7 and Anaconda but when i try to import a library i get always this error:

>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy

I've set up the PYTHONHOME to C:\Python27 and PYTHONPATH to C:\Python27\Lib.

EDIT : content of PATH

In my $PATH variable i have C:\Users\Mattia\Anaconda2, C:\Users\Mattia\Anaconda2\Scripts and C:\Users\Mattia\Anaconda2\Library\bin.

Do i have to set any other env veriables?

like image 642
tia_0 Avatar asked Sep 12 '16 11:09

tia_0


2 Answers

The problem is that you should not have either PYTHONPATH or PYTHONHOME set. They are both pointing to a non-Continuum version of Anaconda, I believe. Anaconda will install (by default) into a directory called Anaconda, either at C:\Anaconda or at C:\Users\USERNAME\Anaconda (IIRC). It is generally recommended that you should not ever set PYTHONPATH or PYTHONHOME, except as a last resort, exactly because of these kinds of problems.

You can see which Python interpreter you're running by doing:

>>> import sys
>>> sys.executable

And then you can see what directories are ending up in your Python library path (where import statements will look for packages, such as scipy and numpy) by doing one of the following:

>>> import sys
>>> sys.path

or the more readable version:

>>> import sys
>>> for p in sys.path:
...    print p
like image 149
IanSR Avatar answered Sep 21 '22 08:09

IanSR


As pointed out by @Mr.F the error was given by the presence of the PYTHONPATH and PYTHONHOME. Deleting them i was able to use the Anaconda version of python.

like image 35
tia_0 Avatar answered Sep 17 '22 08:09

tia_0