bigbatmoegan
bigbatmoegan

Reputation: 1

Template not found pyinstaller BOTTLE

I used pyinstaller to create an executable for a bottle_app for a personal project of mine for a friend. However, after running the executable, it fails to load the template for the home page.

The console for the server only shows the following after a couple refreshes:

Bottle v0.12.19 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit

127.0.0.1 - - [02/Apr/2021 08:01:30] "GET / HTTP/1.1" 500 788
127.0.0.1 - - [02/Apr/2021 08:01:30] "GET /favicon.ico HTTP/1.1" 404 742
127.0.0.1 - - [02/Apr/2021 08:01:35] "GET / HTTP/1.1" 500 788
127.0.0.1 - - [02/Apr/2021 08:01:36] "GET / HTTP/1.1" 500 788

When I run the bottle_app.py file on my machine normally, it works fine.

Here is the command that I ran in pyinstaller

pyinstaller --onefile --add-data 'views/*;views' --add-data 'views/css;views/css' --add-data 'views/js;views/js'--add-data 'pricesBeef.csv;.' --add-data 'pricesHog.csv;.' --add-data 'pricesLamb.csv;.' 'bottle_app.py'

And here is the structure of my application

bottle_app.py
pricesBeef.csv
pricesLamb.csv
pricesHog.csv
views (folder)
->7 html files (inside views)
->css (folder inside of views)
->->css file (only inside of css folder)
->js (folder inside of views)
->->js file (only file inside of js folder)

I'm not getting any traceback errors, which is what's the weird part to me.

Upvotes: 0

Views: 194

Answers (2)

Javiagu13
Javiagu13

Reputation: 86

There is a workaround that worked for me and other people:

import os
import sys

f = open(os.devnull, 'w')
sys.stdout = f
sys.stderr = f

import eel

What it basically does is redirect sys.stderr and sys.stdout to /dev/null.

I want to credit the thread where I found it: https://github.com/python-eel/Eel/issues/654

Upvotes: 0

bigbatmoegan
bigbatmoegan

Reputation: 1

Not a direct answer but a workaround

Use --onedir instead of --onefile and simply use a shortcut to the executable. It will work without needing python already installed, even with .pdy files in the directory

Upvotes: 0

Related Questions