2

Installed Django 1.10.4 and started a project by name test_py. After that created an app by name test_app1.

After creating the app planned to create a installer to run this as a standard-alone app.

Trying to make windows installer using Django 1.10.4 and pyinstaller 3.2 On executing the below command stuck with error, followed by the console output.

$pyinstaller --name=test_py ../test_py/manage.py

131 INFO: PyInstaller: 3.2  
131 INFO: Python: 2.7.12  
131 INFO: Platform: Windows-7-6.1.7601-SP1  
132 INFO: wrote C:\MAMP\htdocs\crumbles\test_django\test_py_package\test_py.spec  
134 INFO: UPX is not available.  
137 INFO: Extending PYTHONPATH with paths  
['C:\\MAMP\\htdocs\\crumbles\\test_django\\test_py',
 'C:\\MAMP\\htdocs\\crumbles\\test_django\\test_py_package']
137 INFO: checking Analysis  
137 INFO: Building Analysis because out00-Analysis.toc is non existent  
137 INFO: Initializing module dependency graph...  
140 INFO: Initializing module graph hooks...  
203 INFO: running Analysis out00-Analysis.toc  
208 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
  required by c:\python27\python.exe  
328 INFO: Found C:\Windows\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest  
330 INFO: Found C:\Windows\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_accf10dbe1dc8ba2.manifest  
332 INFO: Found C:\Windows\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_acd19a1fe1da248a.manifest  
435 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.4940_none ...  
435 INFO: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c.manifest  
437 INFO: Searching for file msvcr90.dll  
437 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcr90.dll  
437 INFO: Searching for file msvcp90.dll  
437 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcp90.dll  
437 INFO: Searching for file msvcm90.dll  
437 INFO: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3c\msvcm90.dll  
545 INFO: Found C:\Windows\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest  
546 INFO: Found C:\Windows\WinSxS\Manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_accf10dbe1dc8ba2.manifest  
547 INFO: Found C:\Windows\WinSxS\Manifests  \amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_acd19a1fe1da248a.manifest  
548 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 4940)  
5515 INFO: Caching module hooks...  
5520 INFO: Analyzing C:\MAMP\htdocs\crumbles\test_django\test_py\manage.py  
8648 INFO: Processing pre-find module path hook   distutils  
8905 INFO: Processing pre-safe import module hook   _xmlplus  
12407 INFO: Loading module hooks...  
12407 INFO: Loading module hook "hook-distutils.py"...  
12407 INFO: Loading module hook "hook-sysconfig.py"...  
12407 INFO: Loading module hook "hook-django.core.management.py"...  
14320 INFO: Excluding import 'IPython'  
14322 WARNING:   Removing import django.core.management.commands.shell from module IPython  
14322 WARNING:   Removing import django.core.management.commands.shell from module IPython.IPShell  
14322 WARNING:   Removing import django.core.management.commands.shell from module IPython.start_ipython  
14323 INFO: Import to be excluded not found: 'Tkinter'  
14323 INFO: Import to be excluded not found: 'matplotlib'  
14324 INFO: Loading module hook "hook-xml.py"...  
14324 INFO: Loading module hook "hook-django.db.backends.py"...  
15119 INFO: Loading module hook "hook-jinja2.py"...  
15141 INFO: Loading module hook "hook-httplib.py"...  
15141 INFO: Loading module hook "hook-django.db.backends.oracle.base.py"...  
15144 INFO: Loading module hook "hook-xml.dom.domreg.py"...  
15144 INFO: Loading module hook "hook-pkg_resources.py"...  
15457 INFO: Loading module hook "hook-django.db.backends.mysql.base.py"...  
15459 INFO: Loading module hook "hook-django.core.mail.py"...  
15537 INFO: Loading module hook "hook-pytz.py"...  
15617 INFO: Loading module hook "hook-encodings.py"...  
16035 INFO: Loading module hook "hook-sqlite3.py"...  
16040 INFO: Loading module hook "hook-django.py"...  
16041 INFO: Django root directory C:\MAMP\htdocs\crumbles\test_django\test_py\test_py  
Traceback (most recent call last):
      File "c:\python27\lib\site-packages\PyInstaller\utils\hooks\subproc\django_import_finder.py", line 37, in <module>
        list(settings.TEMPLATE_LOADERS) + \
      File "c:\python27\lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
        return getattr(self._wrapped, name)
    AttributeError: 'Settings' object has no attribute 'TEMPLATE_CONTEXT_PROCESSORS'
17037 INFO: Collecting Django migration scripts.  
18081 INFO: Loading module hook "hook-django.core.cache.py"...  
18119 INFO: Loading module hook "hook-psycopg2.py"...  
18121 WARNING: Hidden import "mx.DateTime" not found!  
18186 INFO: Looking for ctypes DLLs  
18203 INFO: Analyzing run-time hooks ...  
18215 INFO: Including run-time hook 'pyi_rth_django.py'  
18217 INFO: Including run-time hook 'pyi_rth_pkgres.py'  
18242 INFO: Looking for dynamic libraries  
32332 INFO: Looking for eggs  
32332 INFO: Using Python library C:\Windows\system32\python27.dll  
32332 INFO: Found binding redirects:
[BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'amd64', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 4940), publicKeyToken=u'1fc8b3b9a1e18e3b')]  
32357 INFO: Warnings written to C:\MAMP\htdocs\crumbles\test_django\test_py_package\build\test_py\warntest_py.txt  
33626 INFO: checking PYZ  
33627 INFO: Building PYZ because out00-PYZ.toc is non existent  
33627 INFO: Building PYZ (ZlibArchive) C:\MAMP\htdocs\crumbles\test_django\test_py_package\build\test_py\out00-PYZ.pyz  
35328 INFO: checking PKG  
35328 INFO: Building PKG because out00-PKG.toc is non existent  
35328 INFO: Building PKG (CArchive) out00-PKG.pkg  
35485 INFO: Bootloader c:\python27\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe  
35485 INFO: checking EXE  
35486 INFO: Building EXE because out00-EXE.toc is non existent  
35486 INFO: Building EXE from out00-EXE.toc  
35486 INFO: Appending archive to EXE C:\MAMP\htdocs\crumbles\test_django\test_py_package\build\test_py\test_py.exe  
35518 INFO: checking COLLECT  
35518 INFO: Building COLLECT because out00-COLLECT.toc is non existent  
35518 INFO: Building COLLECT out00-COLLECT.toc  
35543 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 4940)  
arasub
  • 447
  • 5
  • 10

2 Answers2

2

The TEMPLATE_CONTEXT_PROCESSORS setting was deprecated in Django 1.8 and removed in Django 1.10.

It looks as if pyinstaller does not support Django 1.10 (see this issue). Until it is fixed, you could use Django 1.8, which is an LTS (long term support) release.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
0

Open the file django_import_finder.py file, located in C:\Users\<username>\AppData\Local\Programs\Python\Python37\Lib\site-packages\PyInstaller\utils\hooks\subproc

Find the variable named as "hiddenimports"

hiddenimports = list("settings.INSTALLED_APPS") + \
                 list("settings.TEMPLATE_CONTEXT_PROCESSORS") + \
                 list("settings.TEMPLATE_LOADERS") + \
                 ["settings.ROOT_URLCONF"]

Replace the above mentioned variable data with following lines

hiddenimports = list(getattr(settings, "INSTALLED_APPS", [])) + \
                 list(getattr(settings, "TEMPLATE_CONTEXT_PROCESSORS", [])) + \
                 list(getattr(settings, "TEMPLATE_LOADERS", [])) + \
                 [getattr(settings, "ROOT_URLCONF", "")]

This solution is taken from https://gist.github.com/sadnoodles/ceb13afe8dfcf40e92adc0dfbafface2

Ali Khan
  • 143
  • 1
  • 4
  • 9