I have looked at several questions and tried their respective answers, but I cannot seem to understand why VSCode is unable to find the sklearn module.
I use a virtual conda environment called ftds
, in which I have scikit-learn successfully show up when I run conda list
. In jupyter notebook, I use the same ftds
environment and sklearn works fine. In VSCode, I keep getting the ModuleNotFoundError: No module named 'sklearn'
error message.
I ensure I have activated my conda environment using conda activate ftds
prior to running my code. I also ensure that scikit-learn was successfully installed into the ftds
environment using conda. I have the latest version, which is version 1.1.1
at the time of this question.
For further information, I am using MacOS Monterey (Version 12.5). Has anyone had the same issue? I am only able to find those who had issues with jupyter notebook, which is the opposite of my problem.
I have already selected the ftds
environment as the python interpreter in VSCode. Other packages like pandas, numpy, etc. are all functioning as normal.
CodePudding user response:
Maybe it will be a very simple answer, but can you check that the correct interpreter (in your case "ftds") is selected at the bottom right in VSCode?
I sometimes have exactly the same problem in my own work and I realize that most of the time I forget to check it.
CodePudding user response:
If you are sure you have installed the sklearn package, but you still get the ModuleNotFoundError
error message. In most cases you must not choose the corresponding interpreter. Or your sklearn package is not installed in the current python environment.
Please use the pip show sklearn
command to view the installation information of sklearn. Make sure to choose the correct interpreter.
Or activate the environment you want to use and install the sklearn package using the pip install sklearn
command.