Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 236
Jack Avatar asked May 18 '20 10:05

Jack


1 Answers

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
like image 158
bcattle Avatar answered Nov 11 '22 05:11

bcattle