kootenpv / whereami

Uses WiFi signals :signal_strength: and machine learning to predict where you are
GNU Affero General Public License v3.0
5.1k stars 247 forks source link

UnicodeDecodeError when learning #49

Closed MarcTr closed 5 years ago

MarcTr commented 5 years ago

When running whereami learn -l bedroom on Windows 10 with Python 3.5.0 I get this error:


Traceback (most recent call last):
  File "c:\python35\lib\site-packages\access_points\__init__.py", line 14, in ensure_str
    output = output.decode("utf8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 12: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python35\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python35\Scripts\whereami.exe\__main__.py", line 9, in <module>
  File "c:\python35\lib\site-packages\whereami\__main__.py", line 80, in main
    learn(args.location, args.num_samples, args.device)
  File "c:\python35\lib\site-packages\whereami\learn.py", line 26, in learn
    new_sample = sample(device)
  File "c:\python35\lib\site-packages\whereami\get_data.py", line 15, in sample
    aps = wifi_scanner.get_access_points()
  File "c:\python35\lib\site-packages\access_points\__init__.py", line 80, in get_access_points
    results = self.parse_output(ensure_str(out))
  File "c:\python35\lib\site-packages\access_points\__init__.py", line 16, in ensure_str
    output = output.decode("utf16")
  File "c:\python35\lib\encodings\utf_16.py", line 16, in decode
    return codecs.utf_16_decode(input, errors, True)
UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x0a in position 84: truncated data

Is this a known error? Is there any idea how to fix this? Thanks!

MarcTr commented 5 years ago

Replacing output = output.decode("utf16") in the access_points module in line 16 with output = output.decode('ISO-8859-1') fixes this.