Import Error With Python-mysql-connector 1.16, Django 1.6, And Python 3.2.3
Solution 1:
After studying the code it looks like there is some kind of error when referencing that import. I looked into the /lib/python3.2/site-packages/django/utils/six.py file and found where the reference was to the moves.zip_longest module.
First was this reference:
moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves")
Which means it was calling the _MovedItems class, and here it is with the reference to my module that was breaking.
class_MovedItems(_LazyModule):
"""Lazy loading of moved objects"""
_moved_attributes = [
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest")
classMovedAttribute(_LazyDescr):
def__init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
super(MovedAttribute, self).__init__(name)
if PY3:
if new_mod isNone:
new_mod = name
self.mod = new_mod
if new_attr isNone:
if old_attr isNone:
new_attr = name
else:
new_attr = old_attr
self.attr = new_attr
Which then inherits from the _LazyDescr class, but that is a short little object. I don't know where things went wrong, if you map the tuple being passed into the MovedAttribute constructor it maps correctly the old version to the new one. I'm not sure why it's failing but if you remove the import statement in the compiler.py file and simply call itertools zip_longest directly, it all works.
Here's what that looks like. If you are using Python 3, edit the /lib/python3.2/site-packages/mysql/connector/django/compiler.py file, and change line 6 from this:
from django.utils.six.movesimport zip_longest as six_zip_longest
to this:
from itertools import zip_longest
Post a Comment for "Import Error With Python-mysql-connector 1.16, Django 1.6, And Python 3.2.3"