10

I have Django Version 1.7 and Python Version 2.7.5 - I used pip install simplejson and apt-get install python-simplejson commands to solve this problem but it still shows me this exception. Is there any compatibility issue between Django and Python or what is the solution to get out of this exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/root/test_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/root/test_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/root/test_env/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/root/test_env/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/root/test_env/local/lib/python2.7/site-packages/django/apps/config.py", line 123, in create
    import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/root/test_env/local/lib/python2.7/site-packages/extdirect.django-0.3-py2.7.egg/extdirect/django/__init__.py", line 3, in <module>
    from providers import ExtRemotingProvider, ExtPollingProvider
  File "/root/test_env/local/lib/python2.7/site-packages/extdirect.django-0.3-py2.7.egg/extdirect/django/providers.py", line 4, in <module>
    from django.utils import simplejson
ImportError: cannot import name simplejson
4
  • why are you importing simplejson from django.utils? Commented Jan 20, 2015 at 15:20
  • 1
    @dmg - simplejson used to (a while ago) be in there ; ) Commented Jan 20, 2015 at 15:23
  • @ThomasOrozco It's been quite a while i think :D Commented Jan 20, 2015 at 15:24
  • @dmg Yes, it's gone since 1.5. Their code is probably quite outdated. Commented Jan 20, 2015 at 15:24

1 Answer 1

21

Your code isn't compatible with the version of Django you are using.

Django used to ship with simplejson in django.utils, but this was removed in Django 1.5:

django.utils.simplejson

Since Django 1.5 drops support for Python 2.5, we can now rely on the json module being available in Python’s standard library, so we’ve removed our own copy of simplejson. You should now import json instead of django.utils.simplejson.

Unfortunately, this change might have unwanted side-effects, because of incompatibilities between versions of simplejson – see the backwards-incompatible changes section. If you rely on features added to simplejson after it became Python’s json, you should import simplejson explicitly.


You should update the code in extdirect's providers.py to import json instead, or use the version of Django it was designed to work with.

Sign up to request clarification or add additional context in comments.

4 Comments

can i install Django version 1.5 to solve this problem?
@TameenMalik Yes, pip install django==1.5.12. However, note that Django 1.5 isn't supported anymore. You should really consider updating your code to work with a newer version of Django.
Wouldn't it just be fine to import simplejson instead of from django.utils import simplejson?
@guival if you can update the code, then you might as well use the json module (this is already in the answer).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.