Reputation: 11
from sklearn import tree
In python, when I run this code in the interpreter, I get an error:
"modulenotfounderror : no module named 'sklearn'"
How can I fix this problem? I can run this in IDLE version successfully. But running the interpreter, it doesn't not work.
Upvotes: 1
Views: 6685
Reputation: 324
Please check which python version you use in the interpreter:
which python
or python --version
If it is not same with IDLE version, you have to set the environment path first. Because you mentioned .exe
, here is the way to set up on Window machine. Please write one of the following command into your command prompt. (It depends on which version you used in IDLE version.)
set path=%path%;C:\python36
set path=%path%;C:\python27
C:\python36
is where python installation is usually installed on Window machine.
From the command line, if you have multiple versions of python and want to use specified version of python, you can try py -2
or py -3
.
Upvotes: 0
Reputation: 11
By default sklearn module is not pre-packaged with Pyhton. You have to install sklearn module using pip.
Run following command on python console for installing sklearn module:
pip install sklearn
You can also install utility modules that helps sklearn module:
- pip install numpy
- pip install scipy
Upvotes: 1