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

No module named 'bottle-websocket' when running an executable made with PyInstaller, including Eel module #87

Closed
MishaTreedye opened this issue Dec 8, 2018 · 16 comments

Comments

@MishaTreedye
Copy link

MishaTreedye commented Dec 8, 2018

I Made a simple program, tried to make an executable out of it via PyInstaller. No errors whatsoever, but when running this executable it crashes on the first line - import eel, telling - there is no module called 'bottle-websocket'.

I checked pip: eel, bottle-websocket are installed. Can't figure out what's the problem. Runs perfectly as a raw python file, but when executed throws this weird error. Attachments:

main.py:

import eel
import sys

def getcurrentdir():
    a = sys.argv[0].split("\\")
    currentdir = ''
    for i in range(len(a) - 1):
        currentdir += a[i] + "\\"
    return currentdir

eel.init(getcurrentdir + "\\web")
eel.start('main.html', block=False)
while True:
   eel.sleep(10)

Error: CMD error

I found this in PyInstaller Warning file:

bottle.ext' MissingModule
imported by: eel

PyInstaller's Log

@brumar
Copy link

brumar commented Dec 8, 2018

Hello ! Did you follow the readme to create your executable? "bottle_websocket" is a module that pyinstaller isn't smart enough to detect as a dependency. If you check how python -m eel work under the hood by looking into the __main__.py file, you will see that --hidden-module bottle_websocket is passed to pyinstaller to tell him to add it. Unless I misdiagnosed your problem you should either use the recommended python -m eel or use pyinstaller with a similar way you can see in __main__.py

@Treedye
Copy link

Treedye commented Dec 8, 2018

Hi, I was actually following the tutorial until it threw some errors about a web folder not being empty. Now I tried with the empty web folder and it worked, thanks.

@TheHarold
Copy link

Hey guys, Sorry, I'm experiencing the same problem.

I tried to follow the readme and I'm bit unsure about step 4, where it says
"Check the contents of dist folder for extra modules that pyinstaller is incorrectly including"
How would I know which modules are extra? There is no folder or file called extra in my case, maybe there aren't any but when I run the app in dist folder built by python -m eel web.py pl works fine but as soon as I run
pyinstaller.exe --onefile --icon=d:\EEL\favicon.ico --version-file=d:\EEL\pl\version.txt web.py --hidden-import bottle_websocket
the single exe file doesn't work.

I looked into the main.py and I see hidden-import bottle_websocket but not sure how to build it. Please help, all the your support is greatly appreciated.

Thanks

@MishaTreedye
Copy link
Author

MishaTreedye commented Dec 30, 2018

@vimalpatnaik
Hi there,
Try running the pyinstaller this way if you want it to pack eel and bottle-websocket correctly:
py {PATH TO THE EEL's main.py}_main_.py {PATH TO YOUR PY FILE}\py_file.py {PATH TO THE WEB FOLDER} --onefile

e.g. I would use on my pc:
py C:\Users\Misha\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\eel_main_.py C:\Users\Misha\Desktop\ll\main.py C:\Users\Misha\Desktop\ll\web --onefile

@TheHarold
Copy link

I ran the below

d:\EEL>d:\EEL\venv\Scripts\pyinstaller.exe d:\EEL\venv\Lib\site-packages\eel_main_.py d:\EEL\web.py "d:\EEL\pl" --onefile
52 INFO: PyInstaller: 3.4
52 INFO: Python: 3.7.0
53 INFO: Platform: Windows-10-10.0.17134-SP0
59 INFO: wrote d:\EEL_main_.spec
60 INFO: UPX is not available.
61 INFO: Extending PYTHONPATH with paths
['d:\EEL\venv\Lib\site-packages', 'd:\EEL', 'd:\EEL', 'd:\EEL']
62 INFO: checking Analysis
63 INFO: Building Analysis because Analysis-00.toc is non existent
63 INFO: Initializing module dependency graph...
67 INFO: Initializing module graph hooks...
68 INFO: Analyzing base_library.zip ...
2807 INFO: running Analysis Analysis-00.toc
2824 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by d:\eel\venv\scripts\python.exe
3433 INFO: Caching module hooks...
3437 INFO: Analyzing d:\EEL\venv\Lib\site-packages\eel_main_.py
3619 INFO: Processing pre-find module path hook distutils
4304 INFO: Processing pre-find module path hook site
4305 INFO: site: retargeting to fake-dir 'd:\eel\venv\lib\site-packages\PyInstaller\fake-modules'
4938 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
7207 INFO: Analyzing d:\EEL\web.py
8286 INFO: Processing pre-safe import module hook urllib3.packages.six.moves
8928 INFO: Analyzing d:\EEL\pl
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "d:\EEL\venv\Scripts\pyinstaller.exe_main
.py", line 9, in
File "d:\eel\venv\lib\site-packages\PyInstaller_main
.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "d:\eel\venv\lib\site-packages\PyInstaller_main_.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "d:\eel\venv\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "d:\eel\venv\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "", line 17, in
File "d:\eel\venv\lib\site-packages\PyInstaller\building\build_main.py", line 241, in init
self.postinit()
File "d:\eel\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in postinit
self.assemble()
File "d:\eel\venv\lib\site-packages\PyInstaller\building\build_main.py", line 443, in assemble
priority_scripts.append(self.graph.run_script(script))
File "d:\eel\venv\lib\site-packages\PyInstaller\depend\analysis.py", line 219, in run_script
return super(PyiModuleGraph, self).run_script(pathname, caller=caller)
File "d:\eel\venv\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1331, in run_script
with open(pathname, 'rb') as fp:
PermissionError: [Errno 13] Permission denied: 'd:\EEL\pl'

Not sure what permission is required but I can confirm the folder is not in use anywhere.
Thank you for your help

@MishaTreedye
Copy link
Author

MishaTreedye commented Dec 30, 2018 via email

@MishaTreedye
Copy link
Author

MishaTreedye commented Dec 30, 2018 via email

@TheHarold
Copy link

TheHarold commented Jan 3, 2019

Thanks Misha,
It worked on windows but when I run the same on a Mac OS X I get the below error during the packaging.

ERROR: Can not find path ./libtbb.dylib (needed by /Users/vimal/anaconda3/lib/libmkl_tbb_thread.dylib)

When I try to run the app from the dist folder, I see the below in terminal

Vimals-MBP:~ vimal$ /Users/vimal/projects/pl/src/dist/web/web ; exit;
Traceback (most recent call last):
File "web.py", line 1, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/Users/vimal/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.dict)
File "site-packages/eel/init.py", line 3, in
File "site-packages/gevent/monkey.py", line 966, in patch_all
File "site-packages/gevent/monkey.py", line 168, in _notify_patch
File "site-packages/gevent/events.py", line 112, in notify_and_call_entry_points
File "site-packages/pkg_resources/init.py", line 2345, in load
File "site-packages/pkg_resources/init.py", line 2368, in require
File "site-packages/pkg_resources/init.py", line 784, in resolve
pkg_resources.DistributionNotFound: The 'greenlet>=0.4.14' distribution was not found and is required by the application
[13266] Failed to execute script web
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

@MishaTreedye
Copy link
Author

MishaTreedye commented Jan 3, 2019 via email

@TheHarold
Copy link

Thank you that worked but It looks like there is a chrome dependency as I'm getting the below without Chrome install. Could you please advise how to package chrome into the app so it doesn't look for the OS to have chrome installed. Sorry I'm not familiar with this. I appreciate your help.

$ python3 web.py
Traceback (most recent call last):
File "web.py", line 60, in
eel.start()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/eel/init.py", line 112, in start
brw.open(start_urls, options)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/eel/browsers.py", line 34, in open
chr.run(options, start_urls)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/eel/chrome.py", line 18, in run
"Can't find Chrome or Chromium installation")
OSError: Can't find Chrome or Chromium installation

@samuelhwilliams
Copy link
Collaborator

samuelhwilliams commented Jan 3, 2019

Chrome/Chromium doesn't get packaged as part of the app - as it stands, this project requires the end-user to have it already available.

See comment about this from Eel's creator here: #90 (comment)

@AxelRHD
Copy link

AxelRHD commented Feb 6, 2019

I love the simplicity of eel, but I can't get it running with pyupdater (after using the hidden-module flag):

"D:\Dokumente\Development\python-projects\updater-min\pyu-data\deploy\EEL Test.exe" Traceback (most recent call last): File "server.py", line 1, in <module> File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "c:\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module exec(bytecode, module.__dict__) File "site-packages\eel\__init__.py", line 17, in <module> FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\DEU131~1\\AppData\\Local\\Temp\\_MEI171962\\eel\\eel.js' [16328] Failed to execute script server

@MishaTreedye
Copy link
Author

MishaTreedye commented Feb 6, 2019 via email

@AxelRHD
Copy link

AxelRHD commented Feb 6, 2019

pyupdater is wrapping up pyinstaller. But I'm not that experienced with Python to fully understand the changes made to the original pyupdater through Eel and so bringing the ends of Eel and pyupdater together. It would be a great benefit if self updates over pyupdater where possible. Maybe an adaption of the main.py script for pyupdater is possible?

@pauliyobo
Copy link

To those who are still facing this issue.
A probably not optimal way to fix it is to import bottle?websocket in your main file.
so do something like:
import eel
import bottle_websocket

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

@igrG
Copy link

igrG commented Dec 10, 2019

When building for one file in windows with pyinstaller you need to add argument '--hidden-import eel' - this solution is working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants