Python: modul not found after Anaconda installation
Solution 1
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
Solution 2
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.
Related videos on Youtube
tia_0
Actuarial science student and data science passionate. Based in Italy, i'm writing my thesis on sentiment analysis and text mining appliend on the insurance sector. I mainly use R, but i used to program in C/C++, Java and in the glorious x86 Assembly. I learned my programming language basics in high school and now, with the help of SO, i'm becoming better coder and i found myself ready to solve others problems.
Updated on May 21, 2021Comments
-
tia_0 almost 3 years
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
toC:\Python27
andPYTHONPATH
toC:\Python27\Lib
.EDIT : content of PATH
In my $PATH variable i have
C:\Users\Mattia\Anaconda2
,C:\Users\Mattia\Anaconda2\Scripts
andC:\Users\Mattia\Anaconda2\Library\bin
.Do i have to set any other env veriables?
-
phi over 7 yearsWhat is in your $PATH variable? (Try "echo $PATH")
-
tia_0 over 7 yearsI've edited my question
-
Mr.F over 7 yearsDid you try it without modifying
PYTHONPATH
andPYTHONHOME
? -
tia_0 over 7 yearsThanks, this solved the problem because now i see the Anaconda version in the python prompt.
-
-
Jacksonkr almost 7 yearsAhh! This took me FOREVER. I had to delete
export PYTHONPATH=/usr/lib/python2.7:$PYTHONPATH
from my~/.bash_profile
(for osx) -
Atheer about 3 yearsCan you please elaborate? I printed the path, and I see it includes the directory the module is installed in yet it says Module not found!
-
phi about 2 yearsThis helped, I needed to do
unset PYTHONPATH
then everything worked fine for me using the conda base environment. I tried to run a custom installed python module.