Junaid Parkar
Junaid Parkar

Reputation: 31

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

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.

Upvotes: 2

Views: 7363

Answers (4)

Hakan
Hakan

Reputation: 613

Edit with notepad++ than it will work:

C:\Users\yours\AppData\Local\Programs\Python\Python312\Lib\site-packages\eel\__init__.py


Find the exact line from your traceback:
import bottle.ext.websocket as wbs
and replace it with this one below:
import bottle_websocket as wbs

But Eel is chrome based.

Upvotes: 0

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

Upvotes: 2

Ken Verdadero
Ken Verdadero

Reputation: 86

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.

Upvotes: 5

Brave
Brave

Reputation: 588

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

Upvotes: 0

Related Questions