ModuleNotFoundError: No module named 'sklearn'

前端 未结 10 1364
天涯浪人
天涯浪人 2020-12-29 17:37

I want to import sklearn but there is no module apparently:

ModuleNotFoundError: No module named \'sklearn\'

I am using Anaconda and

10条回答
  •  暖寄归人
    2020-12-29 18:19


    Brief Introduction


    When using Anaconda, one needs to be aware of the environment that one is working.

    Then, in Anaconda Prompt one needs to use the following code:

    conda $command -n $ENVIRONMENT_NAME $IDE/package/module
    

    $command - Command that I intend to use (consult documentation for general commands)

    $ENVIRONMENT NAME - The name of your environment (if one is working in the root, conda $command $IDE/package/module is enough)

    $IDE/package/module - The name of the IDE or package or module


    Solution


    If one wants to install it in the root and one follows the requirements - (Python (>= 2.7 or >= 3.4), NumPy (>= 1.8.2), SciPy (>= 0.13.3).) - the following will solve the problem:

    conda install scikit-learn
    

    Let's say that one is working in the environment with the name ML.

    Then the following will solve one's problem:

    conda install -n ML scikit-learn
    

    Note: If one need to install/update packages, the logic is the same as mentioned in the introduction. If you need more information on Anaconda Packages, check the documentation.

提交回复
热议问题