ImportError: cannot import name parse_lookup

2,650 views
Skip to first unread message

Fernando Rodríguez

unread,
Jul 21, 2008, 2:25:05 PM7/21/08
to django users
Hi,

I'm implementing the coltrane blog app in "Practical Django Projects"
and when I try to syncdb I get this error and traceback.

I'm using version 0.97 downloaded from svn.

Any ideas? O:-)

PS Here's the traceback:

Traceback (most recent call last):
File "./manage", line 11, in <module>
execute_manager(settings)
File
"/usr/lib/python2.5/site-packages/django/core/management/__init__.py",
line 301, in execute_manager
utility.execute()
File
"/usr/lib/python2.5/site-packages/django/core/management/__init__.py",
line 248, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/usr/lib/python2.5/site-packages/django/core/management/base.py", line
77, in run_from_argv
self.execute(*args, **options.__dict__)
File
"/usr/lib/python2.5/site-packages/django/core/management/base.py", line
91, in execute
output = self.handle(*args, **options)
File
"/usr/lib/python2.5/site-packages/django/core/management/base.py", line
173, in handle
return self.handle_noargs(**options)
File
"/usr/lib/python2.5/site-packages/django/core/management/commands/shell.py", line 18, in handle_noargs
loaded_models = get_models()
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 136, in get_models
self._populate()
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "/home/fernando/django/elis/models.py", line 6, in <module>
from tagging.fields import TagField
File "/home/fernando/django/tagging/fields.py", line 10, in <module>
from tagging.models import Tag
File "/home/fernando/django/tagging/models.py", line 9, in <module>
from tagging.managers import TagManager, TaggedItemManager
File "/home/fernando/django/tagging/managers.py", line 6, in <module>
from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup

Alaa Salman

unread,
Jul 21, 2008, 2:30:50 PM7/21/08
to Django users


Fernando Rodríguez wrote:
> Hi,
>
> I'm implementing the coltrane blog app in "Practical Django Projects"
> and when I try to syncdb I get this error and traceback.
>
> I'm using version 0.97 downloaded from svn.
> from tagging.managers import TagManager, TaggedItemManager
> File "/home/fernando/django/tagging/managers.py", line 6, in <module>
> from django.db.models.query import QuerySet, parse_lookup
> ImportError: cannot import name parse_lookup

I believe you need to upgrade the tagging app. Get that from its svn.

Karen Tracey

unread,
Jul 21, 2008, 2:32:01 PM7/21/08
to django...@googlegroups.com
If you search this list for likely keywords like the book you are using and the app you are trying to get working you will find that other people have hit the same problem, and I believe they have described solutions.  I don't have time to look up specific posts right now, but I know I have seen this question asked and answered in the last week or so.

Karen

Nicolas Couture

unread,
Aug 18, 2008, 3:33:20 PM8/18/08
to Django users
I am seeing the same exception using tagging-0.2.1 while reading
Practical Django Projects:

remote@CPE001fc6:~/dev/django/cms$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 301, in execute_manager
utility.execute()
File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 248, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 77, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 90, in execute
self.validate()
File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 117, in validate
num_errors = get_validation_errors(s, app)
File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "/home/remote/dev/django/coltrane/models.py", line 7, in
<module>
from tagging.fields import TagField
File "/usr/lib/python2.5/site-packages/tagging/fields.py", line 10,
in <module>
from tagging.models import Tag
File "/usr/lib/python2.5/site-packages/tagging/models.py", line 9,
in <module>
from tagging.managers import TagManager, TaggedItemManager
File "/usr/lib/python2.5/site-packages/tagging/managers.py", line 6,
in <module>
from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup

Using the tagging from trunk (r145):

remote@CPE001fc6:~/dev/django/cms$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 301, in execute_manager
utility.execute()
File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 248, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 77, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 90, in execute
self.validate()
File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 117, in validate
num_errors = get_validation_errors(s, app)
File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
File "/home/remote/dev/django/coltrane/models.py", line 29, in
<module>
class Entry(models.Model):
File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 90, in __new__
new_class.add_to_class(obj_name, obj)
File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 144, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/lib/python2.5/site-packages/tagging/fields.py", line 32,
in contribute_to_class
signals.post_save.connect(self._save, cls, True)
AttributeError: 'object' object has no attribute 'connect'

I am using django r7966.

Would anyone be able to provide more input as to why this is breaking?

Malcolm Tredinnick

unread,
Aug 18, 2008, 3:54:26 PM8/18/08
to django...@googlegroups.com

On Mon, 2008-08-18 at 12:33 -0700, Nicolas Couture wrote:
> [...]

> signals.post_save.connect(self._save, cls, True)
> AttributeError: 'object' object has no attribute 'connect'
>
> I am using django r7966.
>
> Would anyone be able to provide more input as to why this is breaking?

Because you're using the latest version of django-tagging, which has
been updated to support the latest version of Django (currently at
r8434). That includes some changes that are backwards-incompatible. So
you need a slightly older checkout of Django tagging.

Regards,
Malcolm

>
> >
>

Nicolas Couture

unread,
Aug 18, 2008, 4:00:43 PM8/18/08
to Django users
Using django-tagging r133 fixed the problem.

Thank you!

On Aug 18, 3:54 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

--- Z@m ---

unread,
Aug 27, 2008, 8:09:32 AM8/27/08
to Django users
I am also following the Apress book and am trying to implement that
coltrane stuff .
am using the latest django from svn
i got the ""ImportError: cannot import name parse_lookup "" error
initially when i used "tagging-0.2.1"

as told above i tried to check out the latest tagging code from svn

and now i simply cant run
python setup.py install
it says

File "setup.py", line 49, in ?
version_tuple = __import__('tagging').VERSION
File "/home/krishna/Projects/djangoTuts/tagging-r133/tagging/
__init__.py", line 3, in ?
from tagging.managers import ModelTaggedItemManager, TagDescriptor
File "/home/krishna/Projects/djangoTuts/tagging-r133/tagging/
managers.py", line 5, in ?
from django.contrib.contenttypes.models import ContentType
File "/usr/lib/python2.4/site-packages/django/contrib/contenttypes/
models.py", line 1, in ?
from django.db import models
File "/usr/lib/python2.4/site-packages/django/db/__init__.py", line
9, in ?
if not settings.DATABASE_ENGINE:
File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
line 28, in __getattr__
self._import_settings()
File "/usr/lib/python2.4/site-packages/django/conf/__init__.py",
line 57, in _import_settings
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

instead of running the setup file i copied the tagging directory to a
python path .

while i run python manage.py validate , i get
Error: No module named validators

any one please help

Karen Tracey

unread,
Aug 27, 2008, 11:00:03 AM8/27/08
to django...@googlegroups.com

Django has been moving very fast in the last few weeks, making it hard to use latest SVN with any 3rd party app.  django.core.validators was removed from Django in a commit about 8 hours ago (r8616).  django-tagging will need to be updated to account for that.  The right place to file an issue for that or see if someone else has already posted a patch is the django-tagging project page:

http://code.google.com/p/django-tagging/

Alternatively, you can try backing up your SVN checkout to one from before that particular piece was removed, but I'm not sure what other backwards-incompatible changes you might run into.

Karen

Krishnaprasad Varma

unread,
Aug 28, 2008, 1:36:16 AM8/28/08
to django...@googlegroups.com
Thank You Karen , for your instant reply!!


Work as if you have no need of the money.
Love as if nobody ever made you suffer.
Dance as if nobody is watching you.
Sing as if nobody is hearing you.
Live as if the Paradise were on this Earth.

Krishnaprasad Varma    
----------------------------------------------------
krishnapr...@gmail.com            
zam...@ymail.com
+919744111281

fzus...@gmail.com

unread,
Oct 17, 2008, 5:05:06 AM10/17/08
to Django users




> Work as if you have no need of the money.
> Love as if nobody ever made you suffer.
> Dance as if nobody is watching you.
> Sing as if nobody is hearing you.
> Live as if the Paradise were on this Earth.
Good Attitude~I like it~

I have the same error.
Thank You everyone.

Reply all
Reply to author
Forward
0 new messages