Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert django project to exe?

I tried to convert a Django project into exe using pyinstaller, but I am not able to convert it.

My django project is called mysite

This is the command that I executed:

pyinstaller --name=mysite mysite/manage.py

After executing the command above build, dist and mysite.spec were created but dist did not contain 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
like image 577
Ragini Dahihande Avatar asked Dec 27 '16 06:12

Ragini Dahihande


People also ask

Can we develop desktop application using Django?

It's supports running Python, Ruby, and JavaScript code in your application all concurrently interacting with one anther in one application. It's pretty sweet. Show activity on this post. If your Django app is already deployed as a web app then you can wrap the web app in Electron.

Is it possible to compile Django project?

We have to be able to use the project with apache so it cannot be compiled into a standalone binary. The way I think of it is that it will be compiled into libs and these libs will be exposed to the interpreter so it should behave like the current state of the project with python.

How to convert a Python project to an executable file?

Using Auto PY to EXE we can convert.py files to.exe files very easily. This way our Python project will act as a desktop application. And we will be able to run the application on other windows machines without installing Python. In this article, you will learn how to convert a Python project to an executable file.

How do I install Django on my System?

The underlying assumption here is that the reader’s machine has a working version of Python and Python-pip. Django is a well-known Web framework, which allows developers to develop ORM-based apps at a fast pace. If you don’t have Django installed on your system, use pip install Django on a terminal. It will install Django on your system.

How do I create a contact app in Django?

If you don’t have Django installed on your system, use pip install Django on a terminal. It will install Django on your system. Once Django is installed, let’s create a project, within which we will create a contacts app. Open a terminal or command prompt and execute the following command [refer to Figure 2]:


1 Answers

You can find your .exe file inside the /build/mysite/ folder.

like image 89
Muhammad Hammad Avatar answered Sep 30 '22 00:09

Muhammad Hammad