Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed import issue with bottle_websocket #731

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion eel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
import gevent as gvt
import json as jsn
import bottle as btl
import bottle.ext.websocket as wbs
'''
Direct "import bottle websocket as wbs" (before update there is "import bottle.ext.websocket as wbs")
to resolve the issue ModuleNotFoundError: No module named 'bottle.ext.websocket'

To verify the issue and the solution, please refer to the attached file: error-fix.md
'''
# Try to import bottle_websocket, if not found, import bottle.ext.websocket
try:
import bottle_websocket as wbs
except ModuleNotFoundError:
import bottle.ext.websocket as wbs
import re as rgx
import os
import eel.browsers as brw
Expand Down
60 changes: 60 additions & 0 deletions eel/error-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Issue Summary:
When attempting to use the eel library in a Windows 11 environment with Python 3.12.0, I encountered an error where eel is unable to find the bottle.ext.websocket module, even though bottle-websocket is correctly installed in the Python environment.

## Reproducible Example:

### Minimal example demonstrating the issue
```Python
import eel

eel.init("web")
eel.start("index.html")
```


## Expected Behavior:
I expected the script to run without errors and display the web application defined in index.html.
## Actual Behavior:
#### Encountered the following error:
```Python
Traceback (most recent call last):
File "main.py", line 1, in <module>
import eel
File "C:\Users\Chetan\AppData\Local\Programs\Python\Python312\Lib\site-packages\eel\__init__.py", line 16, in <module>
import bottle.ext.websocket as wbs
ModuleNotFoundError: No module named 'bottle.ext.websocket'
```

## Environment Details:
<pre>
Operating System: Windows 11
Python Version: 3.12.0
eel Version: 0.16.0
bottle Version: 0.12.25
bottle-websocket Version: 0.2.9
</pre>

## Steps to Reproduce:
Install eel, bottle, and bottle-websocket using pip.
Run the provided Python script in the specified environment.

## Additional Information:
I have tried a workaround by manually modifying the __init__.py file in the eel package to import bottle_websocket directly, which resolved the issue temporarily.

## Additional Testing:
##### I also tested the script on
<pre>
Operating System: Windows 10
Python Version: 3.9.0
eel Version: 0.16.0
bottle Version: 0.12.25
bottle-websocket Version: 0.2.9
</pre>
##### In both cases, the following imports worked successfully:
```Python
import bottle_websocket as wbs
# or
import bottle.ext.websocket as wbs
```