marcusvolz / strava_py

Create artistic visualisations with your exercise data (Python version)
MIT License
152 stars 18 forks source link

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 379: character maps to <undefined> #19

Closed jmizv closed 1 year ago

jmizv commented 1 year ago

When I execute stravavis against this single attached file (5670595833.gpx.txt, you need to remove the txt extension) it fails with the below error. I tend to add emojis to my strava activity titles so this is in my opinion the problem. Not sure if you could exclude this easily? The files are certainly not encoded with Cp1252.

C:\Users\...>stravavis C:\Users\...
Processing data...
Processing ----------------------------------------   0% -:--:--
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\stravavis\process_data.py", line 13, in process_file
    return process_gpx(fpath)
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\stravavis\process_data.py", line 21, in process_gpx
    activity = gpxpy.parse(open(gpxfile))
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\gpxpy\__init__.py", line 37, in parse
    parser = mod_parser.GPXParser(xml_or_file)
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\gpxpy\parser.py", line 70, in __init__
    self.init(xml_or_file)
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\gpxpy\parser.py", line 82, in init
    text = xml_or_file.read() if hasattr(xml_or_file, 'read') else xml_or_file # type: ignore
  File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 379: character maps to <undefined>
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\...\AppData\Roaming\Python\Python310\Scripts\stravavis.exe\__main__.py", line 7, in <module>
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\stravavis\cli.py", line 51, in main
    df = process_data(args.path)
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\stravavis\process_data.py", line 108, in process_data
    processed = list(it)
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\rich\progress.py", line 168, in track
    yield from progress.track(
  File "C:\Users\...\AppData\Roaming\Python\Python310\site-packages\rich\progress.py", line 1211, in track
    for value in sequence:
  File "C:\Program Files\Python310\lib\multiprocessing\pool.py", line 870, in next
    raise value
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 379: character maps to <undefined>

5670595833.gpx.txt

hugovk commented 1 year ago

Thanks for the report, I couldn't reproduce on macOS or Linux but can on Windows on the CI.

Please see PR https://github.com/marcusvolz/strava_py/pull/20 for a fix.