Getting PyCharm to import sklearn

后端 未结 8 1094
盖世英雄少女心
盖世英雄少女心 2021-02-18 22:32

Beginner here.

I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module nam

8条回答
  •  广开言路
    2021-02-18 22:59

    I had exactly the same problem. I'm using PyCharm with Anaconda3 & Python 3.7, and I've installed other packages into/via PyCharms just fine (such as numpy, scipy, and others). But although scikit-learn (which contains sklearn, that was initially confusing) seems fully installed on my system, including "import sklearn" working outside of PyCharm, I could not get the "import sklearn" to succeed inside PyCharm.

    I finally got a python-expert friend to help me. He verified everything was correctly installed on my system and verified that PyCharm was somehow messing up.

    We finally determined that the venv (virtual environment) was not including scikit-learn (sklearn) even though I had imported it properly into the Project Interpreter in PyCharms.

    Solution: Delete and recreate the VENV, specifically ticking the box Inherit Global Site Packages

    See here: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html for how to create a new virtual environment and get to that parameter.

提交回复
热议问题