我已经在Django中创建了一个项目。我使用pyinstaller创建了它的安装程序。如果我使用python manage.py runserver命令运行该项目,则该项目可以正常运行,没有任何错误,但是我无法通过安装程序运行它。 我在运行安装程序时遇到了错误。
C:\The_Incredibles\Pyinstaller Story\test_proj>.\dist\demo\demo.exe runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x03A15978>
Traceback (most recent call last):
File "site-packages\django-1.10.4-py3.5.egg\django\utils\autoreload.py", line
226, in wrapper
File "site-packages\django-1.10.4-py3.5.egg\django\core\management\commands\ru
nserver.py", line 113, in inner_run
File "site-packages\django-1.10.4-py3.5.egg\django\utils\autoreload.py", line
249, in raise_last_exception
File "site-packages\django-1.10.4-py3.5.egg\django\utils\six.py", line 685, in
reraise
File "site-packages\django-1.10.4-py3.5.egg\django\utils\autoreload.py", line
226, in wrapper
File "site-packages\django-1.10.4-py3.5.egg\django\__init__.py", line 27, in s
etup
File "site-packages\django-1.10.4-py3.5.egg\django\apps\registry.py", line 85,
in populate
File "site-packages\django-1.10.4-py3.5.egg\django\apps\config.py", line 116,
in create
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.admin.apps'
demo.spec
# -*- mode: python -*-
block_cipher = None
a = Analysis(['test1\\manage.py'],
pathex=['C:\\The_Incredibles\\Pyinstaller Story\\test_proj'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='demo',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='demo')
这里是 PyInstaller 的日志记录。
(Sample) C:\The_Incredibles\Pyinstaller Story\test_proj>pyinstaller --name=demo
test1/manage.py
155 INFO: PyInstaller: 3.2
155 INFO: Python: 3.5.2
155 INFO: Platform: Windows-7-6.1.7601-SP1
157 INFO: wrote C:\The_Incredibles\Pyinstaller Story\test_proj\demo.spec
159 INFO: UPX is not available.
168 INFO: Extending PYTHONPATH with paths
['C:\\The_Incredibles\\Pyinstaller Story\\test_proj\\test1',
'C:\\The_Incredibles\\Pyinstaller Story\\test_proj']
168 INFO: checking Analysis
169 INFO: Building Analysis because out00-Analysis.toc is non existent
169 INFO: Initializing module dependency graph...
172 INFO: Initializing module graph hooks...
175 INFO: Analyzing base_library.zip ...
2829 INFO: running Analysis out00-Analysis.toc
2943 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3431 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3438 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3445 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3472 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3481 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3506 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3519 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3525 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3545 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3552 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3564 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
3567 INFO: Caching module hooks...
3572 INFO: Analyzing C:\The_Incredibles\Pyinstaller Story\test_proj\test1\manage
.py
6478 INFO: Loading module hooks...
6478 INFO: Loading module hook "hook-django.core.management.py"...
7684 INFO: Import to be excluded not found: 'matplotlib'
7685 INFO: Import to be excluded not found: 'tkinter'
7685 INFO: Excluding import 'IPython'
7688 WARNING: Removing import django.core.management.commands.shell from modul
e IPython
7689 WARNING: Removing import django.core.management.commands.shell from modul
e IPython.start_ipython
7689 WARNING: Removing import django.core.management.commands.shell from modul
e IPython.IPShell
7691 INFO: Loading module hook "hook-xml.py"...
7693 INFO: Loading module hook "hook-django.py"...
7694 INFO: Django root directory C:\The_Incredibles\Pyinstaller Story\test_proj\
test1\test1
Traceback (most recent call last):
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\utils\hooks\subpr
oc\django_import_finder.py", line 37, in <module>
list(settings.TEMPLATE_LOADERS) + \
File "c:\python\scripts\sample\lib\site-packages\django-1.10.4-py3.5.egg\djang
o\conf\__init__.py", line 54, in __getattr__
return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'TEMPLATE_CONTEXT_PROCESSORS'
8910 INFO: Collecting Django migration scripts.
9818 INFO: Loading module hook "hook-django.core.mail.py"...
9880 INFO: Loading module hook "hook-encodings.py"...
9891 INFO: Loading module hook "hook-django.core.cache.py"...
9916 INFO: Loading module hook "hook-django.db.backends.py"...
10392 WARNING: Hidden import "django.db.backends.__pycache__.base" not found!
10393 INFO: Loading module hook "hook-pydoc.py"...
10395 INFO: Loading module hook "hook-xml.dom.domreg.py"...
10396 INFO: Loading module hook "hook-django.db.backends.oracle.base.py"...
10400 INFO: Loading module hook "hook-django.db.backends.mysql.base.py"...
10403 INFO: Loading module hook "hook-sqlite3.py"...
10478 INFO: checking Tree
10478 INFO: Building Tree because out00-Tree.toc is non existent
10479 INFO: Building Tree out00-Tree.toc
10969 INFO: Looking for ctypes DLLs
10986 INFO: Analyzing run-time hooks ...
10996 INFO: Including run-time hook 'pyi_rth_django.py'
11017 INFO: Looking for dynamic libraries
12997 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:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 695, in getImports
return _getImports_pe(pth)
File "c:\python\scripts\sample\lib\site-packages\PyInstaller\depend\bindepend.
py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
12998 INFO: Looking for eggs
12999 INFO: Using Python library c:\python\scripts\sample\scripts\python35.dll
12999 INFO: Found binding redirects:
[]
13018 INFO: Warnings written to C:\The_Incredibles\Pyinstaller Story\test_proj\b
uild\demo\warndemo.txt
13157 INFO: checking PYZ
13158 INFO: Building PYZ because out00-PYZ.toc is non existent
13158 INFO: Building PYZ (ZlibArchive) C:\The_Incredibles\Pyinstaller Story\test
_proj\build\demo\out00-PYZ.pyz
14732 INFO: checking PKG
14732 INFO: Building PKG because out00-PKG.toc is non existent
14733 INFO: Building PKG (CArchive) out00-PKG.pkg
14784 INFO: Bootloader c:\python\scripts\sample\lib\site-packages\PyInstaller\bo
otloader\Windows-32bit\run.exe
14785 INFO: checking EXE
14785 INFO: Building EXE because out00-EXE.toc is non existent
14785 INFO: Building EXE from out00-EXE.toc
14786 INFO: Appending archive to EXE C:\The_Incredibles\Pyinstaller Story\test_p
roj\build\demo\demo.exe
14807 INFO: checking COLLECT
14808 INFO: Building COLLECT because out00-COLLECT.toc is non existent
14808 INFO: Building COLLECT out00-COLLECT.toc
(Sample) C:\The_Incredibles\Pyinstaller Story\test_proj>
AttributeError: 'Settings' object has no attribute 'TEMPLATE_CONTEXT_PROCESSORS'
和django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured.
。第一个问题是因为在Django 1.11中,TEMPLATE_CONTEXT_PROCESSORS已经过时了。你没有遇到这个问题吗? - ThePhi