3

Estimados, he desarrollado una app con django, pero ahora se me presento un problema al querer compilar a binario (.exe). Estoy usando Django + PyInstaller, si bien puedo llegar a obtener el binario, pero al ejecutarlo se produce un error que obstruye la ejecución de la app.

Cuando ejecuto : Django + PyInstaller el .exe no hace nada, se cierra rapidamente,no puedo ver el error y no activa el servidor ( #> mysite.exe runserver 127.0.0.1:8000)

Detalle de la compilación con PyInstaller

C:\DjangoCRM>pyinstaller --name=mysite manage.py
140 INFO: PyInstaller: 3.2
140 INFO: Python: 3.5.3
140 INFO: Platform: Windows-7-6.1.7601-SP1
140 INFO: wrote C:\DjangoCRM\mysite.spec
140 INFO: UPX is not available.
140 INFO: Extending PYTHONPATH with paths
['C:\\DjangoCRM', 'C:\\DjangoCRM']
140 INFO: checking Analysis
140 INFO: Building Analysis because out00-Analysis.toc is non existent
140 INFO: Initializing module dependency graph...
148 INFO: Initializing module graph hooks...
148 INFO: Analyzing base_library.zip ...
2048 INFO: running Analysis out00-Analysis.toc
2057 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of f
inal executable
  required by C:\Users\AppData\Local\Programs\Python\Python35-32\python.
exe
2101 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-stdio-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2449 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-heap-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2449 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-locale-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2494 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-runtime-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2529 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-math-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2529 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-process-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2556 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-string-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2565 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-conio-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2574 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-convert-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2583 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-filesystem-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2592 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-time-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2601 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-environment-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2601 INFO: Caching module hooks...
2601 INFO: Analyzing C:\DjangoCRM\manage.py
3132 INFO: Processing pre-find module path hook   distutils
5234 INFO: Loading module hooks...
5234 INFO: Loading module hook "hook-django.core.cache.py"...
5287 INFO: Loading module hook "hook-encodings.py"...
5296 INFO: Loading module hook "hook-lib2to3.py"...
5305 INFO: Loading module hook "hook-pkg_resources.py"...
5385 INFO: Processing pre-safe import module hook   win32com
5569 INFO: Loading module hook "hook-django.core.management.py"...
6568 INFO: Import to be excluded not found: 'matplotlib'
6568 INFO: Import to be excluded not found: 'tkinter'
6568 INFO: Excluding import 'IPython'
6568 WARNING:   Removing import django.core.management.commands.shell from modul
e IPython
6568 WARNING:   Removing import django.core.management.commands.shell from modul
e IPython.start_ipython
6568 INFO: Loading module hook "hook-django.py"...
6568 INFO: Django root directory C:\DjangoCRM\DjangoCRM
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\utils\hooks\subproc\django_import_fin
der.py", line 37, in <module>
    list(settings.TEMPLATE_LOADERS) + \
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\django\conf\__init__.py", line 57, in __getattr__
    val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'TEMPLATE_CONTEXT_PROCESSORS'

7818 INFO: Collecting Django migration scripts.
8610 INFO: Loading module hook "hook-sysconfig.py"...
8610 INFO: Loading module hook "hook-xml.py"...
8620 INFO: Loading module hook "hook-django.db.backends.py"...
8953 WARNING: Hidden import "django.db.backends.__pycache__.base" not found!
8953 INFO: Loading module hook "hook-xml.dom.domreg.py"...
8963 INFO: Loading module hook "hook-pythoncom.py"...
9169 INFO: Loading module hook "hook-sqlite3.py"...
9179 INFO: Loading module hook "hook-pytz.py"...
9326 INFO: Loading module hook "hook-pywintypes.py"...
9522 INFO: Loading module hook "hook-win32com.py"...
9816 INFO: Loading module hook "hook-pydoc.py"...
9816 INFO: Loading module hook "hook-django.core.mail.py"...
9856 INFO: Loading module hook "hook-distutils.py"...
9856 INFO: Loading module hook "hook-django.db.backends.mysql.base.py"...
9856 INFO: Loading module hook "hook-django.db.backends.oracle.base.py"...
9964 INFO: Looking for ctypes DLLs
9973 INFO: Analyzing run-time hooks ...
9983 INFO: Including run-time hook 'pyi_rth_django.py'
9983 INFO: Including run-time hook 'pyi_rth_pkgres.py'
9983 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
10003 INFO: Looking for dynamic libraries
11777 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api
-ms-win-crt-utility-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
12189 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api
-ms-win-crt-multibyte-l1-1-0.dll
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 695, in ge
tImports
    return _getImports_pe(pth)
  File "C:\Users\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2-py3.5.egg\PyInstaller\depend\bindepend.py", line 122, in _g
etImports_pe
    dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
12189 INFO: Looking for eggs
12189 INFO: Using Python library C:\Users\AppData\Local\Programs\Python\
Python35-32\python35.dll
12189 INFO: Found binding redirects:
[]
12209 INFO: Warnings written to C:\DjangoCRM\build\mysite\warnmysite.txt
12356 INFO: checking PYZ
12356 INFO: Building PYZ because out00-PYZ.toc is non existent
12356 INFO: Building PYZ (ZlibArchive) C:\DjangoCRM\build\mysite\out00-PYZ.pyz
13989 INFO: checking PKG
13989 INFO: Building PKG because out00-PKG.toc is non existent
13999 INFO: Building PKG (CArchive) out00-PKG.pkg
14028 INFO: Bootloader C:\Users\AppData\Local\Programs\Python\Python35-3
2\lib\site-packages\pyinstaller-3.2-py3.5.egg\PyInstaller\bootloader\Windows-32b
it\run.exe
14038 INFO: checking EXE
14038 INFO: Building EXE because out00-EXE.toc is non existent
14038 INFO: Building EXE from out00-EXE.toc
14038 INFO: Appending archive to EXE C:\DjangoCRM\build\mysite\mysite.exe
14058 INFO: checking COLLECT
14058 INFO: Building COLLECT because out00-COLLECT.toc is non existent
14058 INFO: Building COLLECT out00-COLLECT.toc

Despues de tanto buscar, el problema estaba en encontrar como importar los archivos "hidden" que contiene el directorio hook de pyinstaller. Lo que hice fue crear un archivo como lo explica @FJSevilla y agregar el siguiente script:

#-----------------------------------------------------------------------------
# Copyright (c) 2005-2016, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_submodules
hiddenimports = [
    "dns.rdtypes.*",
    "dns.rdtypes.ANY.*",
    "django.contrib",
    "django.contrib.admin.apps",
    "django.contrib.auth.apps",
    "django.contrib.contenttypes.apps",
    "django.contrib.sessions.models",
    "django.contrib.sessions.apps"

]

Pero ahora surge otro problema, el servidor sigue sin ejecutarse y me muestra el siguiente error:

Performing system checks...

System check identified no issues (0 silenced).

You have 13 unapplied migration(s). Your project may not work properly until you
 apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 23, 2017 - 19:35:32
Django version 1.11.1, using settings 'DjangoCRM.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
 at 0x02C06348>
Traceback (most recent call last):
  File "site-packages\django\core\servers\basehttp.py", line 47, in get_internal
_wsgi_application
  File "site-packages\django\utils\module_loading.py", line 20, in import_string

  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "C:\Users\Carrito\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2.1-py3.5.egg\PyInstaller\loader\pyimod03_importers.py", line
 389, in load_module
    exec(bytecode, module.__dict__)
  File "DjangoCRM\wsgi.py", line 16, in <module>
  File "site-packages\django\core\wsgi.py", line 14, in get_wsgi_application
  File "site-packages\django\core\handlers\wsgi.py", line 151, in __init__
  File "site-packages\django\core\handlers\base.py", line 80, in load_middleware

  File "site-packages\django\utils\module_loading.py", line 20, in import_string

  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'django.contrib.messages.middleware'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\django\utils\autoreload.py", line 227, in wrapper
  File "site-packages\django\core\management\commands\runserver.py", line 147, i
n inner_run
  File "site-packages\django\core\management\commands\runserver.py", line 68, in
 get_handler
  File "site-packages\django\core\servers\basehttp.py", line 57, in get_internal
_wsgi_application
  File "site-packages\django\utils\six.py", line 685, in reraise
  File "site-packages\django\core\servers\basehttp.py", line 47, in get_internal
_wsgi_application
  File "site-packages\django\utils\module_loading.py", line 20, in import_string

  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "C:\Users\Carrito\AppData\Local\Programs\Python\Python35-32\lib\site-pack
ages\pyinstaller-3.2.1-py3.5.egg\PyInstaller\loader\pyimod03_importers.py", line
 389, in load_module
    exec(bytecode, module.__dict__)
  File "DjangoCRM\wsgi.py", line 16, in <module>
  File "site-packages\django\core\wsgi.py", line 14, in get_wsgi_application
  File "site-packages\django\core\handlers\wsgi.py", line 151, in __init__
  File "site-packages\django\core\handlers\base.py", line 80, in load_middleware

  File "site-packages\django\utils\module_loading.py", line 20, in import_string

  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
django.core.exceptions.ImproperlyConfigured: WSGI application 'DjangoCRM.wsgi.ap
plication' could not be loaded; Error importing module: 'No module named 'django
.contrib.messages.middleware''

Quiero saber si alguien tuvo el mismo problema o me puede dar una idea de cual puede ser el error.

4
  • Esta pregunta cae en el causal de cierre demasiado amplia. PyInstaller y cx_Freeze, aunque persiguen el mismo fin, son completamente diferentes, por lo tanto estamos hablando de dos problemas distintos y, probablemente, con diferentes causas. Divide en dos tu pregunta, puedes hacer las preguntas que necesites, pero cada una debe contener toda la información necesaria para comprender por completo el problema, es decir, debes hacer dos preguntas (por lo menos), cada una con un ejemplo mínimo verificable.
    – toledano
    el 19 may. 2017 a las 13:44
  • @toledano ok, ya esta editada.... Sabrías decirme cual puede ser la solución a este problema? Entiendo que son completamente diferentes, con igual objetivo, pero en base al error que surge y cuando se cierra la ventana del .exe rápidamente, no se ejecuta el servidor 127.0.0.1:8000 el 19 may. 2017 a las 21:35
  • Es un error de configuración, seguramente. No hay datos ara saberlo. Busca en la documentación si hay opciones de depuración o registro que puedas activar al empaquetar o al ejecutar.
    – toledano
    el 19 may. 2017 a las 21:56
  • @toledano edite la publicación agregando el detalle de la compilación el 19 may. 2017 a las 22:41

3 respuestas 3

2

En el Changelog for PyInstaller puedes ver que han corregido el siguiente error:

  • (Windows) Correctly decode a bytes object produced by pefile (#1981)

Actualiza a la versión 3.2.1 de pyinstaller.

1
  • Esta bien, en primer lugar el error existente fue solucionado, pero sigo sin poder hacer funcionar el servidor. Ahora el error que me muestra es : `ImportError: No module named 'django.contrib.messages.apps'´ el 22 may. 2017 a las 17:21
1
+50

El error que presentas ahora:

`ImportError: No module named 'django.contrib.messages.apps'´

El problema se debe a que pyinstaller no puede obtener django.contrib, posiblemente sea una importación oculta. Puedes probar a crear un archivo hook para posibilitar a pyinstaller encontrar adecuadamente la libreria:

  • Vete al directorio donde tengas instalado Python (si tienes más de una versión de Python vete logicamente a la que uses con Pyinstaller).

  • Dirigete a Lib\site-packages\PyInstaller\hooks

  • Dentro de la carpeta hooks creas un nuevo archivo y lo llamas:

    hook-django.contrib.py

  • Agrega a ese fichero el contenido siguiente y guardalo:

    #-----------------------------------------------------------------------------
    # Copyright (c) 2013-2016, PyInstaller Development Team.
    #
    # Distributed under the terms of the GNU General Public License with exception
    # for distributing bootloader.
    #
    # The full license is in the file COPYING.txt, distributed with this software.
    #-----------------------------------------------------------------------------
    
    
    from PyInstaller.utils.hooks import collect_submodules
    hiddenimports = collect_submodules('django.contrib')
    

Posteriormente crea desde cero tu ejecutable.

Realmente es difícil dar con la solución a tu problema ya que no tenemos forma de emularlo. Si sigues con problemas sería de gran ayuda que intentaras crear un ejemplo mínimo de aplicación con django que te de el mismo problema que esta y añadir el código para poder reproducirlo nosotros.

5
  • ya había implementado esa solución, también en un include. Ahora estoy con este problema ImportError: No module named 'django.contrib.messages.apps y no encuentro una solución. No me estoy dando cuenta como incluir a ese archivo en PyInstaller. A que haces referencia cuando pides que desarrolle un ejemplo mínimo de la aplicación? Te lo pregunto por que pensé que es lo mismo intentar compilar a .exe el hola mundo con DJango, que desarrollar el proyecto para luego no poder convertirlo en .exe. Mi idea es usar Python, DJango para desarrolla una app de escritorio. el 23 may. 2017 a las 18:00
  • La solución que te doy es para intentar solucionar ese problema 'ImportError: No module named 'django.contrib.messages.apps' precisamente. Con lo de ejemplo me refiero a intenter reprodudir el **mismo error ** que tienes al compilar tu proyecto, compilando un proyecto lo más sencillo posible de django con PyInstaller. Es decir, si un 'hola mundo' al compilar te produce el mismo error que tu proyecto puedes poner el código de ese `'hola mundo' junto a las especificaciones de PyInstaller para que podamos intentar reproducir tu error...
    – FJSevilla
    el 23 may. 2017 a las 18:10
  • ... Lo óptimo seria poder tener acceso a una copia de tu proyecto real para probar la compilación nosotros, como eso es complicado un ejemplo simple pero que te lanzara el mismo error seria de gran ayuda. Saludos.
    – FJSevilla
    el 23 may. 2017 a las 18:11
  • entiendo lo que dices, pero ahora lo que me esta dando resultado es agregar manualmente los import hidden que me pide al momento de ejecutar el .exe. Es decir utilizar : hiddenimports = [ "dns.rdtypes.*", "dns.rdtypes.ANY.*", "django.contrib", "django.contrib.admin.apps", "django.contrib.auth.apps", "django.contrib.contenttypes.apps", "django.contrib.sessions.models", "django.contrib.sessions.apps" ] . el 23 may. 2017 a las 22:39
  • Todavía no logro ejecutar el servidor, pero creo que voy encaminado. Ahora me muestra este error: django.core.exceptions.ImproperlyConfigured: WSGI application 'DjangoCRM.wsgi.ap plication' could not be loaded; Error importing module: 'No module named 'django .contrib.messages.middleware'' Edite la publicación para poner en detalle el error. el 23 may. 2017 a las 22:41
1

Pude hacer funcionar la app, el problema fue siempre los archivos ocultos. Paso el script que me soluciono el problema:

from PyInstaller.utils.hooks import collect_submodules
hiddenimports = [
    "dns.rdtypes.*",
    "dns.rdtypes.ANY.*",
    "django.contrib",
    "django.contrib.admin.apps",
    "django.contrib.auth.apps",
    "django.contrib.contenttypes.apps",
    "django.contrib.sessions.models",
    "django.contrib.sessions.apps",
    "django.contrib.messages.middleware",
    "django.contrib.auth.middleware",
    "django.contrib.sessions.middleware",
    "django.contrib.sessions.serializers"

]

Gracias a todos!

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.