Python EEL module unable to use import bottle.ext.websocket as wbs ModuleNotFoundError: No module named 'bottle.ext.websocket'

3.8k views Asked by At

I am trying to create a GUI in python using plain HTML, CSS, JS. I am using python eel module to create a GUI from it. When i tried to execute .py file it says module not found. Here are the code and error

main.py

import eel

eel.init("./Evo/Body/Comp")

eel.start("desktop.html")

When I execute this code by using

python main.py

It gives this error

main.py", line 1, in <module>
import eel
\Lib\site-packages\eel\__init__.py", line 16, in <module>
import bottle.ext.websocket as wbs
ModuleNotFoundError: No module named 'bottle.ext.websocket'

Earlier it was running well and fine but due to some issue i need to reset my PC. After reset when i re-installed everything then i am unable to run eel module and again and again same error occurs.

3

There are 3 answers

1
Brave On

Make sure you are using auto-py-to-exe to package your app.

After inserting necessary details (script file,, extra files etc), you would see an advanced options tab probably below, click on it to expand it, look for the hidden imports label and insert "bottle-websocket" in the input field representing the hidden imports, that's all you need to do

3
Ken Verdadero On

Problem

If you're using Python 3.12 release, it probably broke the bottle.ext.websocket import

According to the maintainer

As described in #433, auto-py-to-exe fails to launch when run using Python 3.12 due to a bottle issue.

Fix

auto-py-to-exe just released support for Python 3.12.

Pull Request

Release

Upgrade using:

pip install auto-py-to-exe --upgrade --force-reinstall

Workaround (Outdated)

Fortunately, bottle-websocket can be used and should work the same.
I got mine working using Python 3.12.
You just have to change an import in __init__.py in the eel module.

Find this import line:

import bottle.ext.websocket as wbs

and replace it with the one below:

import bottle_websocket as wbs

Make sure you have these up-to-date:

pip install --upgrade bottle-websocket setuptools

Save changes then run auto-py-to-exe again.
Let me know if it works.

0
Артемий Иовчев On

To solve this error, install bottle using this command: pip install git+https://github.com/bottlepy/bottle.git