Search code examples
pythonscikit-learnrocketsktime

ModuleNotFoundError: No module named 'sktime.transformers'


I tried importing

from sktime.transformers.series_as_features.rocket import Rocket

When I run this, I encounter this error ---

File "C:\Users\Success\AppData\Local\Temp/ipykernel_8440/2082396040.py", line 1, in <module>
runfile('C:/Users/Success/Desktop/untitled8.py', wdir='C:/Users/Success/Desktop')

File "C:\Users\Success\anaconda3\lib\site-packages\debugpy\_vendored\pydevd\_pydev_bundle\pydev_umd.py", line 167, in runfile
execfile(filename, namespace)
File "C:\Users\Success\anaconda3\lib\site-packages\debugpy\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile
exec(compile(contents + "\n", file, 'exec'), glob, loc)
File "C:/Users/Success/Desktop/untitled8.py", line 11, in <module>
from sktime.transformers.series_as_features.rocket import Rocket

ModuleNotFoundError: No module named 'sktime.transformers

Solution

  • The package was not installed.

    There are various ways one can install sktime (See here official documentation). Will leave below two options:

    1. Using PyPI

    2. Using conda


    Option 1: Using PyPI

    For that, access the prompt for the environment that you are working on, and run

    pip install sktime
    

    To install sktime with maximum dependencies, including soft dependencies, install with the all_extras modifier:

    pip install sktime[all_extras]
    

    Option 2: Using conda

    For that, access the prompt for the environment that you are working on, and run

    conda install -c conda-forge sktime
    

    To install sktime with maximum dependencies, including soft dependencies, install with the all-extras recipe:

    conda install -c conda-forge sktime-all-extras
    

    By the time I am writing this, this last one (Source):

    does not include dependencies catch-22, pmdarima, and tbats. As these packages are not available on conda-forge, they must be installed via pip if desired. Contributions to remedy this situation are appreciated.


    Notes:

    • In my case when installing following Option 1, I was getting the error

      ERROR: Cannot uninstall 'llvmlite'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

      And, for that, running, in the environment's prompt, the following, solved the problem:

      pip install --ignore-installed llvmlite
      

      If this previous one didn't work, other alternatives, such as

      pip install llvmlite --ignore-installed
      

      Or

      pip install llvmlite
      

      Might work.

    • If the above doesn't work for Option 2, on Anaconda Prompt one can also use pip so the following may help

      pip install sktime
      

      Note, however, that pip doesn't manage dependencies the same way conda does and can, potentially, damage one's installation.

    • If one is using pip on conda as per the previous note, and one gets

      ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\Users\johndoe\anaconda3\envs\Test\Lib\site-packages\~umpy\core\_multiarray_tests.cp310-win_amd64.pyd' Consider using the --user option or check the permissions.

      Doing the following should solve the issue

      pip install sktime --user