[Fixed]-Getting error cannot import name 'six' from 'django.utils' when using Django 3.0.0 latest version

8👍

Short answer: you might want to abandon django-jsonfield.

Based on the traceback, you are using the django-jsonfield package [GitHub], and this is a known issue [GitHub-issue]. It depends on the django.utils.six module, but that module has been removed in .

At the moment, you thus can not use with , and since the last commit to this project is from October 2017, perhaps the project is not that “active” anymore, and it thus might take a very long time (or even never) get fixed. The successor of is ([GitHub]). It was made compatible with by a pull request in October (2019) [GitHub-pr].

7👍

in order to use the six module you can install it directly using pip and then modify the django-jsonfield package accordingly . What I mean is find the files in the package where there is from django.utils import six and replace them with import six. Then it should be working. I faced the same issue when using djongo with django 3.0. I found the respective file and replaced it with the above suggestion. Please note that it is never recommended to do this if you are working on a production level or enterprise level project. I did it for my pet project.

3👍

A specified in Django 3.0 release note, django.utils.six is removed.
In case you need it, it is advised to use pypi packages instead

In your case, jsonfield package might be replaced by native Django’s JSON Field.
Another solution would be to fork jsonfield package yourself to solve you issue, or to make a PR on project’s repo’

0👍

Short Answer
in Django 3.0 just install six:

pip install six

And just use it like:

import six

0👍

In my case it was django-haystac causing this error.
It helped me to upgrade the pip package to the newest beta.

pip install django-haystack==3.0b2
👤Frank

Leave a comment