Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name simplejson. I am using django v1.8 and django-Select2 v4.3.1

Tags:

python

django

My error( command python manage.py runserver) - File "/Users/username/virtual-env/lib/python2.7/site-packages/jsonfield/fields.py", line 3, in from django.utils import simplejson as json ImportError: cannot import name simplejson

I tried solutions from these two posts but they did not work in my case Cannot import name simplejson - After installing simplejson How to solve the ImportError: cannot import name simplejson in Django

like image 313
multimediadev Avatar asked Apr 29 '15 18:04

multimediadev


2 Answers

If this error was in your own code, then you would simply change

from django.utils import simplejson as json

to

import json

after upgrading to Django 1.5 or later.

However, in your case, it looks like the problem is that you've have an old version of django-jsonfield installed. If you upgrade to the latest version (currently 1.03), it should fix the problem.

like image 94
Alasdair Avatar answered Nov 17 '22 00:11

Alasdair


Use import json as simplejson instead

As of django 1.5, simplejson is no longer in django.utils module. So, just use python's JSON module instead.

like image 7
rafaelc Avatar answered Nov 17 '22 00:11

rafaelc