question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows10 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

See original GitHub issue

Followed steps to install mqttwarn on my W10 machine. Everything seemed to work including mqttwarn make-xxx commands. Finally tried running mqttwarn by itself and got strange error messages. Any help?

pip install --upgrade mqttwarn
mqttwarn make-config > mqttwarn.ini
cat mqttwarn.ini
mqttwarn make-samplefuncs > samplefuncs.py
mqttwarn
Traceback (most recent call last):
  File "D:\Program Files (D)\Python37\Scripts\mqttwarn-script.py", line 33, in <module>
    sys.exit(load_entry_point('mqttwarn==0.28.1', 'console_scripts', 'mqttwarn')())
  File "d:\program files (d)\python37\lib\site-packages\mqttwarn\commands.py", line 93, in run
    run_mqttwarn()
  File "d:\program files (d)\python37\lib\site-packages\mqttwarn\commands.py", line 132, in run_mqttwarn
    config = load_configuration(name=scriptname)
  File "d:\program files (d)\python37\lib\site-packages\mqttwarn\configuration.py", line 196, in load_configuration
    return Config(configfile, defaults=defaults)
  File "d:\program files (d)\python37\lib\site-packages\mqttwarn\configuration.py", line 38, in __init__
    self.read_file(f)
  File "d:\program files (d)\python37\lib\configparser.py", line 717, in read_file
    self._read(f, source)
  File "d:\program files (d)\python37\lib\configparser.py", line 1014, in _read
    for lineno, line in enumerate(fp, start=1):
  File "d:\program files (d)\python37\lib\codecs.py", line 714, in __next__
    return next(self.reader)
  File "d:\program files (d)\python37\lib\codecs.py", line 645, in __next__
    line = self.readline()
  File "d:\program files (d)\python37\lib\codecs.py", line 558, in readline
    data = self.read(readsize, firstline=True)
  File "d:\program files (d)\python37\lib\codecs.py", line 504, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
symonjimcommented, Aug 18, 2022

I did that with the .py files. I opened them in notepad and immediately did a “save as” choosing utf8 and overwriting the original. Interestingly all the files I had worked with had said they were going to save as utf8 until I got to samplefuncs.py which said it would save as utf16. I changed that to utf8 and…presto! It works!

PS D:\Program Files (D)\mqttwarn-main\mqttwarn-main> mqttwarn
2022-08-17 18:28:26,596 INFO     [mqttwarn.commands         ] Starting mqttwarn
2022-08-17 18:28:26,597 INFO     [mqttwarn.commands         ] Log level is DEBUG
2022-08-17 18:28:26,597 DEBUG    [mqttwarn.core             ] Trying to load built-in service "file" from "file"
2022-08-17 18:28:26,598 DEBUG    [mqttwarn.core             ] Trying to load service "file" from file "d:\program files (d)\python37\lib\site-packages\mqttwarn\services\file.py"
2022-08-17 18:28:26,599 INFO     [mqttwarn.core             ] Successfully loaded service "file"
2022-08-17 18:28:26,599 DEBUG    [mqttwarn.core             ] Trying to load built-in service "log" from "log"
2022-08-17 18:28:26,600 DEBUG    [mqttwarn.core             ] Trying to load service "log" from file "d:\program files (d)\python37\lib\site-packages\mqttwarn\services\log.py"
2022-08-17 18:28:26,601 INFO     [mqttwarn.core             ] Successfully loaded service "log"
2022-08-17 18:28:26,601 DEBUG    [mqttwarn.core             ] Attempting connection to MQTT broker localhost:1883...
2022-08-17 18:28:26,601 DEBUG    [mqttwarn.core             ] Setting LWT to clients/mqttwarn...
2022-08-17 18:28:28,672 INFO     [mqttwarn.core             ] Publishing status information to mqttwarn/$SYS
2022-08-17 18:28:28,673 INFO     [mqttwarn.core             ] Starting 1 worker threads
2022-08-17 18:28:28,678 DEBUG    [mqttwarn.core             ] Job queue has 0 items to process
2022-08-17 18:28:28,679 DEBUG    [mqttwarn.core             ] Connected to MQTT broker, subscribing to topics...
2022-08-17 18:28:28,680 DEBUG    [mqttwarn.core             ] Cleansession==False; previous subscriptions for clientid mqttwarn remain active on broker
2022-08-17 18:28:28,682 DEBUG    [mqttwarn.core             ] Subscribing to hello/1 (qos=0)
2022-08-17 18:28:28,682 DEBUG    [mqttwarn.core             ] Subscribing to owntracks/+/+ (qos=0)
2022-08-17 18:28:28,683 DEBUG    [mqttwarn.core             ] Subscribing to test/robustness-1 (qos=0)
2022-08-17 18:28:28,683 DEBUG    [mqttwarn.core             ] Subscribing to test/topic-targets-dynamic (qos=0)
2022-08-17 18:28:28,684 DEBUG    [mqttwarn.core             ] Subscribing to test/topic-targets-func (qos=0)

and mosquitto seemed to react. Now I just need to make some adjustments for my setup and tell it what to do when it gets a message.

Thanks for all your help.

Jim

0reactions
amotlcommented, Aug 21, 2022

7b42d6c improves the README correspondingly, so let me close this issue. Thanks again for making us aware of it, Jim.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff ...
When it tries this, it encounters a byte sequence which is not allowed in utf-8-encoded strings (namely this 0xff at position 0). Since...
Read more >
'utf-8' codec can't decode byte 0xff in position 0: invalid start ...
I was able to fix it by opening my .pylintrc file in Notepad++, choosing the UTF-8 encoding there, and then saving the file....
Read more >
'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
UnicodeDecodeError : ' utf-8 ' codec can't decode byte 0xff in position 0 : invalid start byte solved in Django .The error is...
Read more >
How to fix error UnicodeDecodeError utf 8 codec cant decode ...
How to Fix Error "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte" in Python. The below error is...
Read more >
[Fixed] Unicodedecodeerror: 'utf-8' Codec Can't Decode Byte ...
In conclusion, to solve UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte error, you need first to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found