python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

Unicode decode issue #506

Open CXPhoenix opened 3 years ago

CXPhoenix commented 3 years ago

Eel version: 0.14.0 OS: Win10 Enterprise 20H2

Hi, It's honor to use this wonderful library. But when I create the first simple application, there's some issue about unicode decode problem.

Here's the error in runtime:

'***' is my user name

Traceback (most recent call last):
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\threadpool.py", line 167, in __run_task
    thread_result.set(func(*args, **kwargs))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 0: invalid start byte
2021-07-12T06:02:21Z (<ThreadPoolWorker at 0x1967c20ef60 thread_ident=0x262c threadpool-hub=<Hub at 0x1967c0c3340 thread_ident=0x2618>>, <built-in function gethostbyaddr>) failed with UnicodeDecodeError

Traceback (most recent call last):
  File "C:\Users\***\Desktop\pyMacTest\EelProject\main.py", line 3, in <module>
    eel.start(u'main.html')
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\eel\__init__.py", line 180, in start
    run_lambda()
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\eel\__init__.py", line 171, in run_lambda
    return btl.run(
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\bottle.py", line 3137, in run
    server.run(app)
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\bottle_websocket\server.py", line 17, in run
    server.serve_forever()
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\baseserver.py", line 398, in serve_forever
    self.start()
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\baseserver.py", line 336, in start
    self.init_socket()
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\pywsgi.py", line 1546, in init_socket
    self.update_environ()
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\pywsgi.py", line 1558, in update_environ
    name = socket.getfqdn(address[0])
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\_socketcommon.py", line 304, in getfqdn
    hostname, aliases, _ = gethostbyaddr(name)
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\_socketcommon.py", line 276, in gethostbyaddr
    return get_hub().resolver.gethostbyaddr(ip_address)
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\resolver\thread.py", line 66, in gethostbyaddr
    return self.pool.apply(_socket.gethostbyaddr, args, kwargs)
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\pool.py", line 161, in apply
    return self.spawn(func, *args, **kwds).get()
  File "src\\gevent\\event.py", line 329, in gevent._gevent_cevent.AsyncResult.get
  File "src\\gevent\\event.py", line 359, in gevent._gevent_cevent.AsyncResult.get
  File "src\\gevent\\event.py", line 347, in gevent._gevent_cevent.AsyncResult.get
  File "src\\gevent\\event.py", line 327, in gevent._gevent_cevent.AsyncResult._raise_exception
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\_compat.py", line 65, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\***\Desktop\pyMacTest\eelPY\lib\site-packages\gevent\threadpool.py", line 167, in __run_task
    thread_result.set(func(*args, **kwargs))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 0: invalid start byte

Here's my file tree

EELPROJECT │ main.py │ └─web        └─main.html

The code in main.py:

import eel
eel.init(u'web')
eel.start(u'main.html')

The code in web\main.html:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="/eel.js"></script>
</head>

<body>
    Hello world
</body>

</html>

How can I help my self?

ahmed4end commented 3 years ago

i dodged it by reinstalling my win but still curious wut causes it!

RaphSD commented 1 year ago

Hello, This issue is quite old, but for anyone having the same issue, I spent some time digging around and adding breakpoints, the issue on my side was due to my machine's name which had an unsupported utf-8 character (in my case, "ë"). To solve the issue, go to Parameters > System > About > Rename this PC, and rename the PC with a simple name (without special characters). This solved the issue on my side !