I'm packaging a Django app with PyInstaller. I get the following output when I attempt to run the final exe.
Traceback (most recent call last):
File "<string>", line 9, in <module>
File "c:\users\alex\.virtualenvs\pychampion\lib\site-packages\PyInstaller- 2.1.1dev_-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__)
File "Z:\01. Python Development\pychamp\build\project\out00-PYZ.pyz\pychamp", line 4, in <module>
File "c:\users\alex\.virtualenvs\pychampion\lib\site-packages\PyInstaller-2.1.1dev_-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__)
File "Z:\01. Python Development\pychamp\build\project\out00-PYZ.pyz\pychamp.settings", line 13, in <module>
File "c:\users\alex\.virtualenvs\pychampion\lib\site-packages\PyInstaller-2.1.1dev_-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec(bytecode, module.__dict__)
File "Z:\01. Python Development\pychamp\build\project\out00-PYZ.pyz\djcelery", line 22, in <module>
ImportError: cannot import name current_app
The weird thing is that I only get this importerror after I've run pyInstaller. The app runs great before freezing. This issue seemed very similar to what I'm facing as I'm also running from a virtualenv, but renaming the project directory didn't do anything. My current structure is
pychamp
\--pychamp
\--settings.py
\--pyapp
\--manage.py
My guess is that it's another issue with PyInstaller not catching an import but I can't figure out what import I'm missing. Referencing the Pyinstaller Recipe, I've been putting some imports into the manage.py without any luck. I've read through as many different Google searches as I could to figure this out, but I've run out of ideas. Any help is greatly appreciated.
from django.conf import settings
from pychamp import settings
import djcelery
from django.template.loaders.filesystem import Loader
from django.template.loaders.app_directories import Loader
import django.template.defaulttags
import django.template.defaultfilters
import django.template.loader_tags
import django.test
import HTMLParser
import django.contrib.sessions.serializers
UPDATE
I never did figure out what was going on with Celery. I ended up reworking the code to not use Celery and this is my manage.py so pyinstaller would import all the needed libraries.
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pychamp.settings")
from django.conf import settings
import Cookie
import django.test
import HTMLParser
import django.contrib.sessions.serializers
import django.contrib
import django.core.mail.backends.smtp
import django.core.management.commands.sql
import django.core.management.commands.sqlall
import django.core.management.commands.sqlclear
import django.core.management.commands.sqlinitialdata
import django.core.management.commands.sqlsequencereset
import django.template.loader
import django.views.defaults
import django.templatetags
import googlecharts
from googlecharts import templatetags
from googlecharts.templatetags import googlecharts
import django.core.serializers
from django.core.serializers import json
from django.templatetags import future
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)