You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem importing 'jinja2' in an MSI installation on Windows.
This may be caused by the fact that the package name is 'Jinja2' with a captial 'J',
while it must be imported as 'jinja2'.
While my package runs well as Python installation, this import:
fromjinja2importEnvironment, FileSystemLoader
fails, when run as exe:
Traceback (most recent call last):
File "C:\prj\env\wsgidav_build_3.6\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\prj\env\wsgidav_build_3.6\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "wsgidav/server/server_cli.py", line 53, in <module>
File "C:\Prj\git\wsgidav\wsgidav\default_conf.py", line 17, in <module>
from wsgidav.addons.dir_browser import WsgiDavDirBrowser
File "C:\Prj\git\wsgidav\wsgidav\addons\dir_browser\__init__.py", line 32, in <module>
from jinja2 import Environment, FileSystemLoader
ModuleNotFoundError: No module named 'jinja2'
Interestingly, this import works (capital 'J') inside the exe:
importJinja2
though it fails shortly afterwards, because the package itself tries to import sub-modules using the small-caps name:
Traceback (most recent call last):
File "C:\prj\env\wsgidav_build_3.6\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\prj\env\wsgidav_build_3.6\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "wsgidav/server/server_cli.py", line 53, in <module>
File "C:\Prj\git\wsgidav\wsgidav\default_conf.py", line 17, in <module>
from wsgidav.addons.dir_browser import WsgiDavDirBrowser
File "C:\Prj\git\wsgidav\wsgidav\addons\dir_browser\__init__.py", line 22, in <module>
import Jinja2
File "C:\prj\env\wsgidav_build_3.6\lib\site-packages\jinja2\__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
ModuleNotFoundError: No module named 'jinja2'
Details
I use a virtual environment with Python 3.6.5
There I install cx_Freeze-5.1.1-cp36-cp36m-win32.whl
also pip install Jinja2, and it gets installed as <env>\Lib\site-packages\jinja2\.
I run python setup.py bdist_msi from this environment.
The resulting package is stored as <project>\build\exe.win32-3.6\lib\Jinja2
The import exception can be observed, when running <project>\build\exe.win32-3.6\wsgidav.exe
I was able to fix a similar issue with PyYAML (that must be imported as 'yaml')
like so in my setup.py:
install_requires= ["defusedxml", "jsmin", "Jinja2", "PyYAML"]
ifuse_cx_freeze:
# cx_Freeze seems to be confused by module name 'PyYAML' which# must be imported as 'yaml', so we rename here. However it must# be listed as 'PyYAML' in the requirements.txt and be installed!install_requires.remove("PyYAML")
install_requires.append("yaml")
however, this does not work for Jinja, maybe because Windows file names are not
case sensitive:
* SimpleDomainController
* tried to add NT-DC to MSI
* Hotfix for broken Jinja2 import in MSI installer
See marcelotduarte/cx_Freeze#418
* Add pywin32 to MSI installer
* Move dir_browser from addons to own package
* Move some modules around
I have a problem importing 'jinja2' in an MSI installation on Windows.
This may be caused by the fact that the package name is 'Jinja2' with a captial 'J',
while it must be imported as 'jinja2'.
While my package runs well as Python installation, this import:
fails, when run as exe:
Interestingly, this import works (capital 'J') inside the exe:
though it fails shortly afterwards, because the package itself tries to import sub-modules using the small-caps name:
Details
cx_Freeze-5.1.1-cp36-cp36m-win32.whl
pip install Jinja2
, and it gets installed as<env>\Lib\site-packages\jinja2\
.python setup.py bdist_msi
from this environment.<project>\build\exe.win32-3.6\lib\Jinja2
<project>\build\exe.win32-3.6\wsgidav.exe
I was able to fix a similar issue with PyYAML (that must be imported as 'yaml')
like so in my setup.py:
however, this does not work for Jinja, maybe because Windows file names are not
case sensitive:
I would really apreciate any thoughts or hints, that would help to solve or
work-around this problem.
Thank you.
The text was updated successfully, but these errors were encountered: