0
votes

I am using the windows command prompt to install the scikit learn library using the command pip install -U scikit-learn. However, whenever I try to import it into my program I get an error stating that there is no module named 'sklearn'. Also, whenever I download the library using pip, for some reason, my pip package installer seems to break and pip is no longer recognized as a command on my cmd. I have numerous other modules which work perfectly fine so I don't see a reason as to why I can't get this specific library to work. I am still quite new to this kind of thing, so maybe I am missing something.

Traceback (most recent call last):

File "<pyshell#0>", line 1, in import sklearn File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn_init_.py", line 82, in from .base import clone File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in from .utils import IS_32BIT File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils_init.py", line 20, in from scipy.sparse import issparse File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse_init_.py", line 227, in from .base import * File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\base.py", line 4, in from .sputils import (isdense, isscalarlike, isintlike, File "C:\Users\Ryan\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\sparse\sputils.py", line 8, in from scipy._lib._util import prod ModuleNotFoundError: No module named 'scipy._lib._util'

1
Do you use Anaconda?Alexey Larionov
No I do not. Will I be able to get it to work with my visual studio code, which is the IDE I use?Glooc
You should include the exact pip command you've run when you mention "try to download the library using pip" and the error messages you've got. Are you running something different from pip install -U scikit-learn? Also, it is probably worth trying running import sklearn in a python terminal before doing it on an IDE. Sometimes the IDE is not accessing the right environment.Homero Esmeraldo
I receive no error messages during pip installation process. The module is simply 'not recognized' whenever i try to import it into my program on VSCode. However, a couple minutes after the installation, For some reason whenever i try to run any pip command later, i receive a '' 'pip' is not recognized as an internal or external command" message and have to reinstall python again on my system each time.Glooc

1 Answers

1
votes

Try to upgrade pip to newest version by python -m pip install --upgrade pip considering you are still using Windows. And then try to download sciKitLearn by pip install sklearn This is how I had solved my problem but keep note that it was about a year ago

If all this doesn't work, try VirtualEnv.