Skip to content Skip to sidebar Skip to footer

Unicodedecodeerror While Starting The App Under Windows With Pycharm

The problem is that when i try to start the application (app.py) i get the following error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 5: invalid start by

Solution 1:

Problem is native letter ł (probably in name Michał) which has code 0xb3 but in Window-1250, not UTF-8.

Maybe you have this letter not only in folder name but also in hostname (computer's name) and then script has problem when it try to get this name in

hostname, aliases, ipaddrs = gethostbyaddr(name)

You can see this line error message.

Maybe if you change hostname in Windows's setting then it will works.


I don't use Windows but when I was using Windows (and DOS) there was always good rule: don't use native (Polish) letters (and spaces) in file/folder name. The same can be with hostname.


Windows may use three different encoding (Code Page) - Window-1250 (CP-1250) for filenames, CP-852 for text in console and UTF-8 in your script. Sometimes also LATIN2 (ISO-8859-2) in old HTML files.

See: image which polish code pages (encodings) on page Python Unicode - decode & encode

Solution 2:

The method gethostbyaddr will get the name of your computer, if it's not English, cmd will result in this error.

You need to rename your windows computer by english totally, and reboot your computer

Post a Comment for "Unicodedecodeerror While Starting The App Under Windows With Pycharm"