djangosixgraphene-django

django_graphene looking for package "six" in the wrong place?


I'm trying to use graphene-django, and a having some issues with the "six" package. It's installed, but it's installed as its own package, and graphene-django seems to be expecting it under django.utils

  File "C:\Users\mjnic\.virtualenvs\phoenix-demo-C42C_PgQ\lib\site-packages\graphene_django\settings.py", line 18, in <module>
    from django.utils import six
ImportError: cannot import name 'six' from 'django.utils' (C:\Users\mjnic\.virtualenvs\phoenix-demo-C42C_PgQ\lib\site-packages\django\utils\__init__.py)

Path for six:

>>> import six
>>> print(six.__file__)
C:\Users\mjnic\.virtualenvs\phoenix-demo-C42C_PgQ\lib\site-packages\six.py

I've checked the source for graphene_django and in the settings.py it seems to be looking specifically at the django path.

This module provides the `graphene_settings` object, that is used to access
Graphene settings, checking for user settings first, then falling
back to the defaults.
"""
from __future__ import unicode_literals

from django.conf import settings
from django.test.signals import setting_changed
from django.utils import six

I'm using pipenv to manage my environment, and I've uninstalled and reinstalled six, and the various graphene packages several times now trying to sort this out, to no avail.

So how can I either move the installation of six so that it's located at django.utils.six, alternatively change the setup so that graphene-django is looking at the currently installed location instead (doesn't seem possible looking at the source)?


Solution

  • After much frustration I have discovered the answer. My Pipfile actually specified Django = "*" (yes, I know ...), and it seems that six has been removed from django.utils in version 3. Specifying the version as <3.0 and downgrading seems to have fixed the issue for me!

    See here for the issue report on graphene-django. Could be handy for anybody else facing the same issue.

    https://github.com/graphql-python/graphene-django/issues/771