dpgaspar / Flask-AppBuilder

Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/
BSD 3-Clause "New" or "Revised" License
4.69k stars 1.36k forks source link

trouble with pyinstaller #1546

Closed EnriqueGautoSand closed 3 years ago

EnriqueGautoSand commented 3 years ago

I have several problems trying to pass my application to an executable using auto-py-to-exe that use pyinstaller i have the next files and folders

proyect:

------|app ------------|templates ------------|translations ------------|static ------------| init.py ------------|others.py ------------|views.py ------------|models.py ------|babel ------|app.db ------|run.py ------|config.py

i use this command pyinstaller --noconfirm --onedir --console --name "pruebafinal" --add-data "C:/Users/Usuario/Documents/roberto/roberto/aplicacion/app.db;." --add-data "C:/Users/Usuario/Documents/roberto/roberto/aplicacion/babel;babel/" --add-data "C:/Users/Usuario/Documents/roberto/roberto/aplicacion/app;app/" --add-data "C:/Users/Usuario/Documents/roberto/roberto/aplicacion/config.py;." --add-data "C:/Users/Usuario/Documents/roberto/roberto/aplicacion/__pycache__;__pycache__/" --hidden-import "flask_appbuilder" --hidden-import "flask" --hidden-import "os" --hidden-import "sys" --hidden-import "webbrowser" --hidden-import "reportlab" --hidden-import "datetime" --hidden-import "sqlalchemy" --hidden-import "flask_babel" --hidden-import "flask_sqlalchemy" --hidden-import "flask_wtf" --hidden-import "PIL" --hidden-import "sqlalchemy" --hidden-import "sqlalchemy_utils" --hidden-import "sqlite3" --hidden-import "wtforms" --hidden-import "xml" --hidden-import "defusedxml" "C:/Users/Usuario/Documents/roberto/roberto/aplicacion/run.py"

first error dont found the templates folder

2021-01-11 09:33:59,534:INFO:werkzeug: * Running on http://localhost:7000/ (Press CTRL+C to quit)
2021-01-11 09:33:59,574:ERROR:app:Exception on / [GET]
Traceback (most recent call last):
  File "flask\app.py", line 2446, in wsgi_app
  File "flask\app.py", line 1951, in full_dispatch_request
  File "flask\app.py", line 1820, in handle_user_exception
  File "flask\_compat.py", line 39, in reraise
  File "flask\app.py", line 1949, in full_dispatch_request
  File "flask\app.py", line 1935, in dispatch_request
  File "flask_appbuilder\views.py", line 41, in index
  File "flask_appbuilder\baseviews.py", line 281, in render_template
  File "flask\templating.py", line 138, in render_template
  File "jinja2\environment.py", line 869, in get_or_select_template
  File "jinja2\environment.py", line 830, in get_template
  File "jinja2\environment.py", line 804, in _load_template
  File "jinja2\loaders.py", line 113, in load
  File "flask\templating.py", line 60, in get_source
  File "flask\templating.py", line 89, in _get_source_fast
jinja2.exceptions.TemplateNotFound: appbuilder/index.html

i put this on my init.py

if getattr(sys, 'frozen', False):
    template_folder = os.path.join(sys._MEIPASS, 'templates')
    static_folder = os.path.join(sys._MEIPASS, 'static')
    app = Flask(__name__, template_folder=template_folder, static_folder=static_folder)
else:
    app = Flask(__name__)

app.config.from_object("config")
db = SQLA(app)
appbuilder = AppBuilder(app, db.session)

but i only solve that adding the templates and static folder at level of run.py and in templates foulder i put the appbuilder folder with the others templates this solve the error of template dont found, but have other error when load template dont load bootstrap files and on my config.py i have BABEL_DEFAULT_LOCALE = "es" but load in english

ab.css:1 Failed to load resource: the server responded with a status of 404 (NOT FOUND)
bootstrap.min.css:1 Failed to load resource: the server responded with a status of 404 (NOT FOUND)
font-awesome.min.css:1 Failed to load resource: the server responded with a status of 404 (NOT FOUND)
flags16.css:1 Failed to load resource: the server responded with a status of 404 (NOT FOUND)
select2.css:1 

image

Environment windows 10

Flask-Appbuilder version: F.A.B Version: 3.0.1.

pip freeze output:

pip freeze absl-py==0.7.1 alabaster==0.7.12 altgraph==0.16.1 anaconda-client==1.7.2 anaconda-navigator==1.9.7 apispec==3.3.2 appdirs==1.4.4 APScheduler==3.6.3 arrow==0.16.0 asn1crypto==0.24.0 astor==0.8.0 astroid==2.2.5 attrdict==2.0.1 attrs==19.1.0 auto-py-to-exe==2.7.11 Babel==2.7.0 backcall==0.1.0 beautifulsoup4==4.7.1 bitmex-ws==0.3.1 bleach==3.1.0 blinker==1.4 bottle==0.12.19 bottle-websocket==0.2.9 certifi==2019.6.16 cffi==1.12.3 chardet==3.0.4 Click==7.0 client==0.0.1 cloudpickle==1.2.1 clyent==1.2.2 coinpayments-py==0.1.0 colorama==0.4.1 conda==4.7.10 conda-build==3.17.8 conda-package-handling==1.3.11 conda-verify==3.1.1 cryptography==2.7 cycler==0.10.0 decorator==4.4.0 defusedxml==0.6.0 distlib==0.3.1 dnspython==2.0.0 docutils==0.15.1 dominate==2.6.0 Eel==0.12.4 email-validator==1.1.1 entrypoints==0.3 eth-account==0.3.0 eth-hash==0.2.0 eth-keyfile==0.5.1 eth-keys==0.2.2 eth-rlp==0.1.2 eth-typing==2.1.0 eth-utils==1.5.1 etherscan==0.2.3 fab-addon-audit==0.0.1 filelock==3.0.12 Flask==1.1.1 Flask-AppBuilder==3.0.1 Flask-Babel==1.0.0 Flask-BabelPkg==0.9.6 Flask-Bootstrap==3.3.7.1 Flask-JSGlue==0.3.1 Flask-JWT-Extended==3.24.1 Flask-Login==0.4.1 Flask-Mail==0.9.1 flask-ngrok==0.0.25 Flask-OpenID==1.2.5 Flask-SocketIO==4.2.1 Flask-SQLAlchemy==2.4.4 Flask-SQLAlchemy-Session==1.1 Flask-WTF==0.14.3 future==0.17.1 gast==0.2.2 gevent==1.4.0 gevent-websocket==0.10.1 glob2==0.7 greenlet==0.4.15 grpcio==1.21.1 h5py==2.9.0 hexbytes==0.1.0 idna==2.8 imagesize==1.1.0 importlib-metadata==1.7.0 ipykernel==5.1.1 ipython==7.7.0 ipython-genutils==0.2.0 ipywidgets==7.5.0 isort==4.3.21 itsdangerous==1.1.0 jedi==0.13.3 Jinja2==2.10.1 json5==0.8.4 jsonschema==3.0.1 jupyter-client==5.3.1 jupyter-core==4.5.0 jupyterlab==1.0.2 jupyterlab-server==1.0.0 Keras==2.2.4 Keras-Applications==1.0.8 Keras-Preprocessing==1.1.0 keyring==18.0.0 kiwisolver==1.1.0 lazy-object-proxy==1.4.1 libarchive-c==2.8 lxml==4.4.1 macholib==1.11 Markdown==3.1.1 MarkupSafe==1.1.1 marshmallow==3.7.1 marshmallow-enum==1.5.1 marshmallow-sqlalchemy==0.23.1 matplotlib==3.1.2 mccabe==0.6.1 menuinst==1.4.16 mistune==0.8.4 mkl-fft==1.0.12 mkl-random==1.0.2 mkl-service==2.0.2 mock==3.0.5 mpld3==0.3 navigator-updater==0.2.1 nbconvert==5.5.0 nbformat==4.4.0 notebook==6.0.0 numpy==1.16.4 numpydoc==0.9.1 olefile==0.46 packaging==19.0 pandas==1.0.1 pandocfilters==1.4.2 parso==0.5.0 pefile==2019.4.18 pickleshare==0.7.5 Pillow==6.1.0 pkginfo==1.5.0.1 playsound==1.2.2 prison==0.1.3 prometheus-client==0.7.1 prompt-toolkit==2.0.9 protobuf==3.8.0 psutil==5.6.3 psycopg2==2.8.5 py-etherscan-api==0.8.0 py2exe==0.9.2.2 pycodestyle==2.5.0 pycosat==0.6.3 pycparser==2.19 pycryptodome==3.8.1 pyflakes==2.1.1 pygame==1.9.6 Pygments==2.4.2 pyinstaller==4.1 pyinstaller-hooks-contrib==2020.11 PyJWT==1.7.1 pylint==2.3.1 pyOpenSSL==19.0.0 pyparsing==2.4.0 PyQt5==5.10.1 PyQt5-sip==4.19.17 pyreadline==2.1 pyrsistent==0.14.11 PySide2==5.14.0 PySocks==1.7.0 python-dateutil==2.8.0 python-engineio==3.11.2 python-socketio==4.4.0 python3-openid==3.2.0 pytz==2019.1 pywin32==223 pywin32-ctypes==0.2.0 pywinpty==0.5.5 PyYAML==5.1.1 pyzmq==18.0.0 QtAwesome==0.5.7 qtconsole==4.5.2 QtPy==1.8.0 reportlab==3.5.53 requests==2.22.0 requests-cache==0.5.0 rlp==1.1.0 rope==0.14.0 ruamel-yaml==0.15.46 scikit-learn==0.19.2 scipy==1.3.0 seaborn==0.10.0 selenium==3.141.0 Send2Trash==1.5.0 shiboken2==5.14.0 sip==4.19.8 six==1.12.0 snowballstemmer==1.9.0 soupsieve==1.9.2 speaklater==1.3 Sphinx==2.1.2 sphinxcontrib-applehelp==1.0.1 sphinxcontrib-devhelp==1.0.1 sphinxcontrib-htmlhelp==1.0.2 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.2 sphinxcontrib-serializinghtml==1.1.3 spyder==3.3.6 spyder-kernels==0.5.1 SQLAlchemy==1.3.19 SQLAlchemy-Utils==0.36.8 tensorboard==1.13.1 tensorflow==1.13.1 tensorflow-estimator==1.13.0 tensorflow-gpu==1.13.1 termcolor==1.1.0 terminado==0.8.2 testpath==0.4.2 tornado==6.0.3 tqdm==4.32.1 traitlets==4.3.2 twilio==6.49.0 tzlocal==2.1 urllib3==1.24.2 utils==0.9.0 virtualenv==20.0.28 visitor==0.1.3 wcwidth==0.1.7 webencodings==0.5.1 websocket==0.2.1 websocket-client==0.46.0 Werkzeug==0.15.4 whichcraft==0.6.1 widgetsnbextension==3.5.0 win-inet-pton==1.1.0 wincertstore==0.2 wrapt==1.11.2 WTForms==2.3.3 XlsxWriter==1.3.6 zipp==3.1.0

Describe the expected results

the software after generated the exe it could work translated to spanish

Describe the actual results

first problem dont found the index.html template and basetemplate this i solve ading the appbuilder foulder into the templates folders but then in my config.py i have set up BABEL_DEFAULT_LOCALE = "es" but it apears only on spanish

Steps to reproduce

config.py have BABEL_DEFAULT_LOCALE = "es"

in init.py i have

if getattr(sys, 'frozen', False):
    template_folder = os.path.join(sys._MEIPASS, 'templates')
    static_folder = os.path.join(sys._MEIPASS, 'static')
    app = Flask(__name__, template_folder=template_folder, static_folder=static_folder)
else:
    app = Flask(__name__)

app.config.from_object("config")
db = SQLA(app)
appbuilder = AppBuilder(app, db.session)
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Feel free to reopen it if it's still relevant to you. Thank you