ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
422 stars 146 forks source link

Running rubiks.py returns ImportError #343

Closed chaNcharge closed 6 years ago

chaNcharge commented 6 years ago

I followed all the instructions on the readme file in the MindCub3r demo, however, when I run it, it returns:

Traceback (most recent call last): File "rubiks.py", line 6, in from rubikscolorresolver import RubiksColorSolverGeneric File "/usr/local/lib/python3.4/dist-packages/rubikscolorresolver/init.py", line 4, in from sklearn.cluster import KMeans ImportError: No module named 'sklearn'

I tried to install sklearn, numpy, and scipy via pip, but it hangs during installation. Is there something I'm missing?

ddemidov commented 6 years ago

Where does rubikscolorresolver package come from? Is it one by @dwalton76? I think sklearn module that it tries to import should come from http://scikit-learn.org, but I am not sure it works on the EV3.

dwalton76 commented 6 years ago

yep that is one of mine, it lives at https://github.com/dwalton76/rubiks-color-resolver

@chaNcharge can you try

$ sudo apt-get install python3-pip
$ sudo python3 -m pip install numpy
$ sudo python3 -m pip install scikit-learn
$ sudo python3 -m pip install scipy
$ sudo python3 -m pip install git+https://github.com/dwalton76/rubiks-color-resolver.git
dwalton76 commented 6 years ago

I thought about this some more, none of those libraries are needed until you are dealing with a cube that is 4x4x4 or larger so I changed the code to lazy load those. So @chaNcharge do sudo python3 -m pip install git+https://github.com/dwalton76/rubiks-color-resolver.git and then to test to make sure everything is working do

rubiks-color-resolver.py --rgb '{"1": [39, 71, 43], "2": [54, 90, 62], "3": [5, 16, 17], "4": [41, 74, 50], "5": [64, 103, 74], "6": [33, 17, 5], "7": [30, 53, 31], "8": [50, 86, 59], "9": [33, 17, 6], "10": [24, 9, 4], "11": [23, 11, 5], "12": [22, 12, 4], "13": [5, 18, 18], "14": [6, 19, 21], "15": [4, 18, 17], "16": [6, 18, 18], "17": [4, 17, 18], "18": [4, 15, 15], "19": [5, 14, 12], "20": [5, 17, 18], "21": [28, 35, 6], "22": [32, 18, 6], "23": [44, 22, 8], "24": [29, 38, 7], "25": [25, 15, 5], "26": [33, 16, 5], "27": [28, 35, 6], "28": [4, 23, 9], "29": [5, 31, 11], "30": [28, 15, 4], "31": [5, 30, 11], "32": [6, 37, 14], "33": [35, 18, 5], "34": [4, 27, 10], "35": [4, 32, 10], "36": [33, 19, 5], "37": [35, 65, 37], "38": [5, 29, 11], "39": [5, 24, 8], "40": [51, 86, 60], "41": [32, 14, 6], "42": [27, 11, 4], "43": [49, 83, 58], "44": [25, 11, 4], "45": [25, 12, 5], "46": [22, 30, 6], "47": [31, 40, 7], "48": [25, 11, 5], "49": [28, 38, 7], "50": [37, 45, 9], "51": [25, 11, 4], "52": [23, 32, 6], "53": [29, 38, 7], "54": [5, 31, 10]}'

You should see this at the end of the output

2017-09-05 08:00:04,267    INFO: Cube

           Gr Gr Bu
           Gr Gr OR
           Gr Gr OR
 Rd Rd Rd  Bu Bu Ye  Wh Wh OR  Gr Wh Wh
 Bu Bu Bu  OR OR Ye  Wh Wh OR  Gr Rd Rd
 Bu Bu Bu  OR OR Ye  Wh Wh OR  Gr Rd Rd
           Ye Ye Rd
           Ye Ye Rd
           Ye Ye Wh

2017-09-05 08:00:04,267    INFO: 
          01 02 03 
          04 05 06 
          07 08 09 

10 11 12  19 20 21  28 29 30  37 38 39 
13 14 15  22 23 24  31 32 33  40 41 42 
16 17 18  25 26 27  34 35 36  43 44 45 

          46 47 48 
          49 50 51 
          52 53 54 

UULUUFUUFRRFRRFRRFLLDFFDFFDDDBDDBDDRBBBLLLLLLURRUBBUBB
chaNcharge commented 6 years ago

Thanks a lot @dwalton76, it works without an issue now!