0

im trying to install sklearn to my PC but even though i've installed it using pip, when I type import sklearn it says: "sklearn" is not accessed (Pylance) Import "sklearn" could not be resolved (Pylance)

I have tried uninstalling it and reinstalling it on the VSCode terminal and on cmd but the problem just persists, can anyone please tell me how to fix

3 Answers3

1

I fixed it by realising I was installing "sklearn" rather than "scikit-learn", so yeah i kind of look like an idiot

  • 2
    Very common footgun that has definitely burned me in the past. Fortunately the Python Package Index is [rolling out a deprecation strategy for the package](https://pypi.org/project/sklearn/) that should make `pip install sklearn` return an error come December of 2023. – Roger Filmyer Mar 09 '23 at 19:59
0

Double check that you are running the right copy of Python in your interpreter in VSCode (in the bottom right of your window here)

VSCode screenshot indicating where the interpreter menu is located for the Python extension

The general issue is that your python installation isn't looking in the right place for where pip is installing packages. This question has some good discussion on how to fix this.

Marcelo Paco's comment is reasonable - reloading the VSCode window may kick VSCode into realizing which Python interpreter to use.

Roger Filmyer
  • 676
  • 1
  • 8
  • 24
0

I had a similar issue. If normal installation doesn't work you can try this:

python -m pip install scikit-learn
Amuoeba
  • 624
  • 9
  • 28