1

my python windows app is using jinja2, after freezing the app via qx_freeze I'm getting an error with jinja2 function. From how I understand is that jinja2 is trying to use pkg_resources, which is working fine before I freeze my app. This is my setup.py file:

import cx_Freeze
import sys
import os
import os.path
import re

# Dependence

base = None
if sys.platform == 'win32':
      base = 'Win32GUI'

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TLC_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

executables = [cx_Freeze.Executable('app.py',base='Win32GUI')]

cx_Freeze.setup(
      name="app",
      version="0.1",
      description="*********",
      executables= executables,
      options={'build_exe':{'packages':['tkinter','re','pandas','premailer','os','ttkthemes','jinja2','independentsoft'],
      'include_files':[
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
      ]
      }}
      )

And this is where jinja2 fails when frozen:

def __init__(self, package_name, package_path="templates", encoding="utf-8"):
    from pkg_resources import DefaultProvider
    from pkg_resources import get_provider
    from pkg_resources import ResourceManager

I don't know how to import pkg_resources into my .exe
  • Can you show your requirements.txt? – Danizavtz May 21 '20 at 12:51
  • Hello, I'm still new to python and this is my first project. When I tried to create requirements.txt it came out blanc. I used command pip freeze > requirements.txt.I created my venv with pycharm, I don't know if that helps. – Boris Klenovsek May 21 '20 at 19:08
  • If you do not have a `requirements.txt` how do you manage dependencies? – Danizavtz May 21 '20 at 19:39
  • Like I mentioned before, I'm still learning Python. I was almost done with my first project and I didn't even know what requirements.txt is untill you asked for it. Now I realize that I have more things to learn. I already started at the moment you asked for it. – Boris Klenovsek May 21 '20 at 19:53

0 Answers0