1

When I try to start my django app on openshift I get the following message. Hence deploying fails...

File "wsgi/djangoProjectNew/manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 312, in execute
    django.setup()
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
File "/var/lib/openshift/55555511111114444444444/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/apps/config.py", line 119, in create
    import_module(entry)
File "/opt/rh/python27/root/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named django

This app is a copy of an app I set up several months ago. I changed all relevant paths, names, etc. It's running fine locally.

Isn't it strange that the last command __init__.py runs outside the virtualenv?

I'm using the python2.7 cartridge and the github openshift example https://github.com/openshift/django-example This app uses django 1.8.0 as a dependency.

This is installed apps from djangoProject.settings

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myDjangoApp',
    'djcelery',
    'kombu.transport.django',
    'progressbarupload',
    'widget_tweaks',
)

Django is installed:

[djangoProject-USERNAME.rhcloud.com data]\> which python
/var/lib/openshift/55555511111114444444444/python/virtenv/bin/python
[djangoProject-USERNAME.rhcloud.com data]\> python 
Python 2.7.8 (default, Aug  4 2016, 09:29:33) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 8, 0, 'final', 0)
>>> 

After further playing around, I can say that it is related to one or all of these INSTALLED_APPS:

    'djcelery',
    'kombu.transport.django',
    'progressbarupload',

This is pip freeze:

amqp==2.1.1
Babel==0.9.6
billiard==3.5.0.1
celery==4.0.0rc6
Django==1.8
django-celery==3.1.17
django-smartfields==1.0.9
django-widget-tweaks==1.4.1
docutils==0.11
Extractor==0.6
Jinja2==2.6
kombu==4.0.0rc6
MarkupSafe==0.11
MySQL-python==1.2.3
nose==1.3.0
numpy==1.7.1
prelive==1.0
psycopg2==2.5.1
Pygments==1.5
pytz==2016.7
scipy==0.12.1
simplejson==3.2.0
six==1.7.3
Sphinx==1.1.3
SQLAlchemy==0.7.9
vine==1.1.3
virtualenv==13.1.0
Werkzeug==0.8.3
wheel==0.24.0
user3620060
  • 131
  • 1
  • 14
  • 1
    Sounds like django is installed locally, but not on openshift... – Jens Astrup Oct 31 '16 at 20:00
  • sorry for forgetting to mention this. Django is installed. I updated the question. – user3620060 Oct 31 '16 at 21:11
  • OpenShift 2 requires you to explicitly activate the virtual environment in your WSGI script file or app.py file. Are you doing that? – Graham Dumpleton Oct 31 '16 at 23:40
  • I tried out activating the virtualenv in wsgi.py and my application file. None changes anything. Also when I manually ssh into the app and activate the virtualenv it doesnt change anything. The example from github also doesn't explicitely activate the virtualenv and it works out of the box. Only when I start adding my files it breaks. Furthermore I can see from the stack trace that **it is using** virtualenv . The virtualenv is under: `/var/lib/openshift/55555511111114444444444/python/virtenv/` – user3620060 Nov 01 '16 at 13:59
  • I did some further testing and edited the question again - does this now ring a bell for anybody? – user3620060 Nov 02 '16 at 21:09

2 Answers2

1

The reason is that 'kombu.transport.django' is no longer available in kombu 4.0.0.

So the "ImportError: No module named django" is complaining about a module in the package kombu, not package Django.

Using kombu 3.0.** should fix it.

azalea
  • 11,402
  • 3
  • 35
  • 46
0

I added this to my setup.py and now it works.

install_requires=[
    'Django==1.8', 
    'django-celery==3.1.16', 
    'kombu==3.0.26', 
    'django-widget-tweaks==1.4.1', 
    'celery==3.1.18', 
    'django-crispy-forms==1.4.0', 
    ],
user3620060
  • 131
  • 1
  • 14