pythonnumpyscikit-learnpython-importsix

Python import error: cannot import name 'six' from 'sklearn.externals'


I'm using numpy and mlrose, and all i have written so far is:

import numpy as np
import mlrose

However, when i run it, it comes up with an error message:

 File "C:\Users\<my username>\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mlrose\neural.py", line 12, in <module>
    from sklearn.externals import six
ImportError: cannot import name 'six' from 'sklearn.externals' (C:\Users\<my username>\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sklearn\externals\__init__.py)

Any help on sorting this problem will be greatly appreciated.


Solution

  • Solution: The real answer is that the dependency needs to be changed by the mlrose maintainers.

    A workaround is:

    import six
    import sys
    sys.modules['sklearn.externals.six'] = six
    import mlrose