Jinja2通过cx_freeze到exe不起作用。 pkg_resources问题

问题描述 投票:1回答:1

我的python Windows应用正在使用jinja2,通过qx_freeze冻结应用后,我在jinja2函数中遇到错误。据我了解,jinja2正在尝试使用pkg_resources,在冻结我的应用程序之前,它运行良好。这是我的setup.py文件:

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'),
      ]
      }}
      )

这是jinja2冻结时失败的地方:

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
python jinja2 cx-freeze pkg-resources
1个回答
0
投票

创建新的VENV之后,我设法获得了我的requirements.txt

cachetools==4.1.0
certifi==2020.4.5.1
chardet==3.0.4
cssselect==1.1.0
cssutils==1.0.2
idna==2.9
independentsoft.msg==1.6
Jinja2==2.11.2
lxml==4.5.1
MarkupSafe==1.1.1
numpy==1.18.4
pandas==1.0.3
Pillow==7.1.2
premailer==3.7.0
python-dateutil==2.8.1
pytz==2020.1
requests==2.23.0
six==1.15.0
ttkthemes==3.0.0
urllib3==1.25.9
© www.soinside.com 2019 - 2024. All rights reserved.