I've been using django to interface with a couple of data source libraries,
both of which use six. There appears to be some sort of conflict problem
between six and django.utils.six which causes ImportErrors.

For example, using the Reddit library "praw":

> from six.moves.urllib.parse import parse_qs, urlparse, urlunparse

ImportError: No module named urllib.parse

or from Google-API:

>>> from apiclient.discovery import build

from six.moves import urllib

ImportError: cannot import name urllib

When looking around the web for problems with six, the common answer is to
change the order of the import so that the more recent copy is first,
obviously I can't do that if things are wrapped inside of django.  I have
tried six v1.4, 1.8 and 1.9, none of which work.

I have tried explicitly removing django.utils.six's _SixMetaPathImporter
from sys.meta_path before doing the imports and it still fails.  In
debugging I have found that anything in six that is a MovedModule will fail
to import but those things that are MovedAttribute objects still work.

I have django installed in a virtualenv.  I have tried this with Django
1.7.5 and 1.8.2 with no luck.  If I run the import commands from the python
interpreter directly they work, but if I run the same import command from
"./manage.py shell" the import fails.

In playing around I instrumented the non-django copy of six and was able to
get it to list all of its module values including those it can't import.
So on one hand the module thinks it is there, but the import hook fails.

I'm not even 100% sure this is a django problem and not a conflict with
some other library in the virtualenv, I do know that something that
"manage.py" brings into the path is causing issues.  Any help would be
greatly appreciated.  My head is sore from banging against this particular
wall.
...ct

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANk-4bi7S5GPPpZNNLGY%3DzFge4u_2cL4R7eGdK8h2pVx5gHbpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to