I can open an interactive shell from the command line, just not from PyDev inside Eclipse. Clicking through Django --> Shell with django environment
I get the following output:
import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
C:\Python27\python.exe 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
PyDev console: using default backend (IPython not available).
from django.core import management;import carbon_factors.settings as settings;management.setup_environ(settings)
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setup_environ'
To try and resolve this I have updated PyDev to 3.2.0 with no change to the output. I'm using Django 1.6.
I have looked at the comment here which pointed me here. However the accepted answer seems to have already be built into Django/PyDev as the line it suggests to change in manage.py
is already changed.
setup_environ
has been deprecated in Django 1.6. See here.
As far as I can tell, PyDev has hardcoded this method of starting a Django shell into the right click project -> "shell with Django environment" menu item. This is an issue that PyDev needs to address (hopefully by simplifying whatever they are doing under the hood with that command to just "python manage.py shell"!) I don't believe their menu command currently calls manage.py, which is why the other answers didn't work for you.
Option 1 As a hacky workaround, add "from django.conf import settings; settings.configure()" to the initial interpreter commands in Window->Preferences->PyDev->Interactive Console. You'll still see the error but at least you'll have your settings.
Option 2 In Window->Preferences->Interpreter->Environment tab, add an environment variable "DJANGO_SETTINGS_MODULE" with the Python dotted path to your settings file (exclude the '.py' at the end).