'Python: already install package but can't use (sklearn)
I have already installed sklearn and scikit-learn, the version of sklearn showed 0.0(use pip show instr.)
I've tried many ways to install or update packages, but when I ran the code it shows:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import sklearn
ModuleNotFoundError: No module named 'sklearn'
when I install again, it shows:
Requirement already satisfied: sklearn in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (0.0)
Requirement already satisfied: scikit-learn in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from sklearn) (1.0.2)
Requirement already satisfied: numpy>=1.14.6 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (1.22.3)
Requirement already satisfied: scipy>=1.1.0 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (1.8.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (3.1.0)
Requirement already satisfied: joblib>=0.11 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from scikit-learn->sklearn) (1.1.0)
can anyone tell me how to deal with it? thanks!!!
Solution 1:[1]
You can check whether the virtual environment installed sklearn is consistent with the one used for your code.
Solution 2:[2]
thanks for everyone! I found that there was the error on the environment variables, it links to old version of python that i havn't deleted, I reinstall python and set the right path, and it works!
Solution 3:[3]
You can check which environment you installed that package? Example, with Miniconda, and if I have more than 1 env then I will switch to the specific env, and activate it and install lib. Then you need to check what env you setup in your development tool (ex: Visual Code).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | joeweibin |
| Solution 2 | Jonny CasHsu |
| Solution 3 | Sunderam Dubey |
