我尝试使用pyinstaller将Django项目转换为exe,但我无法转换它。
我的django项目名为mysite
这是我执行的命令:
pyinstaller --name=mysite mysite/manage.py
执行上述build
命令后,dist
和mysite.spec
已创建,但dist
未包含mysite.exe
root@ayachp-ind:~/mysite_demo# pyinstaller --name=mysite mysite/manage.py
24 INFO: PyInstaller: 3.2
24 INFO: Python: 2.7.6
24 INFO: Platform: Linux-3.5.0-39-generic-x86_64-with-Ubuntu-14.04-trusty
25 INFO: wrote /root/mysite_demo/mysite.spec
30 INFO: UPX is not available.
31 INFO: Extending PYTHONPATH with paths
['/root/mysite_demo/mysite', '/root/mysite_demo']
31 INFO: checking Analysis
31 INFO: Building Analysis because out00-Analysis.toc is non existent
31 INFO: Initializing module dependency graph...
33 INFO: Initializing module graph hooks...
147 INFO: running Analysis out00-Analysis.toc
165 INFO: Caching module hooks...
168 INFO: Analyzing /root/mysite_demo/mysite/manage.py
7765 INFO: Processing pre-find module path hook distutils
9195 INFO: Loading module hooks...
9195 INFO: Loading module hook "hook-distutils.py"...
9196 INFO: Loading module hook "hook-django.core.management.py"...
12362 INFO: Processing pre-safe import module hook _xmlplus
14241 INFO: Excluding import 'IPython'
14242 WARNING: Removing import django.core.management.commands.shell from module IPython
14243 WARNING: Removing import django.core.management.commands.shell from module IPython.IPShell
14243 WARNING: Removing import django.core.management.commands.shell from module IPython.start_ipython
14244 INFO: Import to be excluded not found: 'Tkinter'
14244 INFO: Import to be excluded not found: 'matplotlib'
14245 INFO: Loading module hook "hook-xml.py"...
14245 INFO: Loading module hook "hook-PIL.py"...
14247 INFO: Import to be excluded not found: 'FixTk'
14247 INFO: Import to be excluded not found: 'Tkinter'
14247 INFO: Import to be excluded not found: 'PyQt5'
14247 INFO: Import to be excluded not found: 'PySide'
14247 INFO: Import to be excluded not found: 'PyQt4'
14247 INFO: Loading module hook "hook-httplib.py"...
14248 INFO: Loading module hook "hook-PIL.Image.py"...
14717 INFO: Loading module hook "hook-xml.dom.domreg.py"...
14717 INFO: Loading module hook "hook-django.core.mail.py"...
14768 INFO: Loading module hook "hook-django.template.loaders.py"...
15658 INFO: Loading module hook "hook-django.db.backends.py"...
17662 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
17664 INFO: Import to be excluded not found: 'FixTk'
17664 INFO: Import to be excluded not found: 'Tkinter'
17665 INFO: Loading module hook "hook-encodings.py"...
18458 INFO: Loading module hook "hook-sqlite3.py"...
18460 INFO: Loading module hook "hook-django.py"...
18461 INFO: Django root directory /root/mysite_demo/mysite/mysite
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/utils/hooks/subproc/django_import_finder.py", line 108, in <module>
base_module = __import__(base_module_name, {}, {}, ["urls"])
File "/root/mysite_demo/mysite/mysite/urls.py", line 5, in <module>
url(r'^polls/', include('polls.urls')),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/root/mysite_demo/mysite/polls/urls.py", line 3, in <module>
from . import views
File "/root/mysite_demo/mysite/polls/views.py", line 3, in <module>
from django.urls import reverse
ImportError: No module named urls
19946 INFO: Collecting Django migration scripts.
23633 INFO: Loading module hook "hook-django.core.cache.py"...
23690 INFO: Loading module hook "hook-sysconfig.py"...
23751 INFO: Loading module hook "hook-django.db.backends.oracle.base.py"...
23754 INFO: Loading module hook "hook-pkg_resources.py"...
24642 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ImportError: No module named win32com
24706 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ImportError: No module named win32com
24894 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ImportError: No module named win32com
25037 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ImportError: No module named win32com
25216 INFO: Loading module hook "hook-django.db.backends.mysql.base.py"...
25530 INFO: Looking for ctypes DLLs
25652 INFO: Analyzing run-time hooks ...
25670 INFO: Including run-time hook 'pyi_rth_django.py'
25673 INFO: Including run-time hook 'pyi_rth_pkgres.py'
25694 INFO: Looking for dynamic libraries
26348 INFO: Looking for eggs
26348 INFO: Python library not in binary depedencies. Doing additional searching...
26370 INFO: Using Python library /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
26396 INFO: Warnings written to /root/mysite_demo/build/mysite/warnmysite.txt
28573 INFO: checking PYZ
28573 INFO: Building PYZ because out00-PYZ.toc is non existent
28574 INFO: Building PYZ (ZlibArchive) /root/mysite_demo/build/mysite/out00-PYZ.pyz
31528 INFO: checking PKG
31528 INFO: Building PKG because out00-PKG.toc is non existent
31528 INFO: Building PKG (CArchive) out00-PKG.pkg
31565 INFO: Bootloader /usr/local/lib/python2.7/dist-packages/PyInstaller/bootloader/Linux-64bit/run
31565 INFO: checking EXE
31565 INFO: Building EXE because out00-EXE.toc is non existent
31565 INFO: Building EXE from out00-EXE.toc
31566 INFO: Appending archive to ELF section in EXE /root/mysite_demo/build/mysite/mysite
31584 INFO: checking COLLECT
31585 INFO: Building COLLECT because out00-COLLECT.toc is non existent
31585 INFO: Building COLLECT out00-COLLECT.toc
答案 0 :(得分:0)
进入构建文件夹,然后进入mysite文件夹,其中包含您想要的exe文件,谢谢