1

I am getting this error message when I try to run the shell from Eclipse Neon while I can successfully run the Django shell from command window. I am using Python 3.4 and Django 1.10. Any idea where the problem is?

enter image description here

WSGI file:

'''
WSGI config for MyProject project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
'''

import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyProject.settings")

application = get_wsgi_application()
Ibo
  • 4,081
  • 6
  • 45
  • 65
  • I don't know why @Hybrid deleted his answer because "You have an accidental indentation in your wsgi.py file" – e4c5 Dec 30 '16 at 06:58
  • But then again this question is off topic because it's a typo – e4c5 Dec 30 '16 at 06:59
  • @e4c5 "wsgi.py" file is generated by django and I have not touched it, so I doubt it is a typo. plus, I can run it from command prompt. – Ibo Dec 30 '16 at 20:48
  • Well the error still says extra space so why don't you open it and see? – e4c5 Dec 31 '16 at 01:28
  • @e4c5 I checked "wsgi.py" file, there is no unexpected indent. Should I look somewhere else? – Ibo Jan 03 '17 at 22:00
  • why not update the post with that file – e4c5 Jan 04 '17 at 00:45
  • @e4c5 I just updated it – Ibo Jan 04 '17 at 00:48
  • that does look ok unless there is a hidden character somewhere – e4c5 Jan 04 '17 at 00:49
  • @e4c5 the error message is: File "", line 1 application = get_wsgi_application() ^ IndentationError: unexpected indent I think it is a different file, but I cannot figure out where the file is. – Ibo Jan 04 '17 at 00:56
  • I would suggest opening a console and starting the same Environment: Paste in each line as in the output window and see if you get a fail with something else: e.g. AttributeError: module 'django.core.management' has no attribute 'setup_environ' which version of Django are you using? – PythonTester Mar 15 '17 at 13:29
  • compare your version to the following: django.get_version() < '1.5' django.get_version() >= '1.7' – PythonTester Mar 15 '17 at 13:39
  • @ PythonTester I am using Django 1.10 and since I got frustrated I built the project from scratch and tried not to use Eclipse. – Ibo Mar 16 '17 at 17:57

1 Answers1

2

I beleive This is a known bug in Eclipse Pydev.

https://www.brainwy.com/tracker/PyDev

Fixed for 5.6

Git: 2c8cd03 2017-03-12 Fabio Zadrozny #PyDev-752: Django version not detected if > 1.10

And a fix has been posted for it.

You could try start a python shell as normal, then:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
import os; os.environ['DJANGO_SETTINGS_MODULE'] = '<Project Name>.settings'; import django
sys.path.append(os.path.expanduser('<path to your project>'))
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Replace 'Project Name' with your project name and 'path to your project' with your path

alternatively, use a pre 1.10 version of Django i.e 1.7

PythonTester
  • 831
  • 7
  • 11