简体   繁体   中英

Cannot import name simplejson - After installing simplejson

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM