Getting PyCharm to import sklearn

Beginner is here.

I am trying to use sklearn in pycharm . When importing sklearn , the error message "Import error: no module named sklearn " sklearn . The project interpreter in pycharm set to 2.7.10 (/anaconda/bin/python.app), which must be correct. According to the default preferences of the project interpreter, I see all the anacondas packages. I double-clicked and installed the scikit learn and sklearn . I still get the message "Import failed: no module named sklearn"

Does anyone know how to solve this problem?

+15
source share
7 answers

To make sure Scikit-learn is installed on your PyCharm IDE, go to File> Preferences and look for Interpreter. Select Project Interpreter, and if you don't see Scikit-learn in the package list, click the + sign on the right end. This brings us another window with a search bar where you can enter "Scikit-learn" and install (see. Screenshots). Hope this helps.

Screenshots: Interpreter Settings , Install package

+36
source

Double check your python interpreter. Check if you have chosen the correct interpreter when creating the project.

See this - Interpreter check image when creating a project.

Or you can check your interpreter from the project view in the External Libraries section.

See this - Image of interpreter check from Project view.

In your case, if you did not select 2.7.10 ( /anaconda/bin/python.app ) as your interpreter for the project at the beginning, the program will still Import error: No module named sklearn the same Import error: No module named sklearn .

+2
source

note that in the search for packages " Scikit-learn " instead of " sklearn "

+2
source

The same thing happens to me, I fixed it by choosing File Menu-> Default Settings-> Project Interpreter β†’ Press the + button and enter "sklearn". Click the install button. Installation will be done in 10-20 seconds.

If the problem persists, please check the PyCharm Interpreter path. Sometimes Python 2.7 and Python 3.6 are installed on your computer, and there may be a conflict when choosing one of them.

+1
source

For Mac OS:

PyCharm β†’ Settings β†’ Project Interpreter β†’ Double-click on an item (a new window with a search option will open) β†’ mention β€œScikit-learn” in the search bar β†’ Install packages β†’ After installation, close this new window β†’ OK in the existing window

and you are done.

0
source

I had exactly the same problem. I use PyCharm with Anaconda3 and Python 3.7, and I installed other packages on / through PyCharms just fine (such as numpy, scipy and others). But although scikit-learn (which contains sklearn, which was initially confusing) seems to be fully installed on my system, including "import sklearn" working outside of PyCharm, I could not get import sklearn to work successfully inside PyCharm.

I finally got a python expert friend who helped me. He checked that everything was installed correctly on my system, and that PyCharm was somehow messed up.

We finally determined that there was no scikit-learn (sklearn) in venv (virtual environment), although I correctly imported it into the project interpreter in PyCharms.

Decision. Uninstall and recreate the VENV by checking the Inherit Global Site Packages box.

See here: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html to learn how to create a new virtual environment and get this setting.

0
source

go to terminal type python -m pip install scikit-learn then press Enter. give him a few seconds. Will be done. Sample image

0
source

All Articles