ImportError: cannot import name actions

1,505 views
Skip to first unread message

rok

unread,
Oct 15, 2013, 8:56:56 AM10/15/13
to django-d...@googlegroups.com
I have recently been testing the 1.6b4 tag with a new app we are writing, using apache and wsgi. However, I could not get rid of the following issue happening on every request:

...
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]   File "/home/rok/apps/django-trunk/django/contrib/gis/admin/__init__.py", line 2, in <module>
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]     from django.contrib.admin import autodiscover, site, AdminSite, ModelAdmin, StackedInline, TabularInline, HORIZONTAL, VERTICAL
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]   File "/home/rok/apps/django-trunk/django/contrib/admin/__init__.py", line 6, in <module>
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]     from django.contrib.admin.sites import AdminSite, site
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]   File "/home/rok/apps/django-trunk/django/contrib/admin/sites.py", line 3, in <module>
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1]     from django.contrib.admin import ModelAdmin, actions
[Tue Oct 15 12:50:36 2013] [error] [client 127.0.0.1] ImportError: cannot import name actions

by doing the following change, I could get rid of what looked like a circular import issue:
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -1,6 +1,7 @@
 from functools import update_wrapper
 from django.http import Http404, HttpResponseRedirect
-from django.contrib.admin import ModelAdmin, actions
+from django.contrib.admin import ModelAdmin
+from django.contrib.admin.actions import delete_selected
 from django.contrib.admin.forms import AdminAuthenticationForm
 from django.contrib.auth import REDIRECT_FIELD_NAME
 from django.contrib.contenttypes import views as contenttype_views
@@ -46,7 +47,7 @@ class AdminSite(object):
         self._registry = {}  # model_class class -> admin_class instance
         self.name = name
         self.app_name = app_name
-        self._actions = {'delete_selected': actions.delete_selected}
+        self._actions = {'delete_selected': delete_selected}
         self._global_actions = self._actions.copy()
 
     def register(self, model_or_iterable, admin_class=None, **options):

Switching to 1.5.4 resolves the issue as well (even though the sites.py code is the same). What is more, this did not occur in the development environment when using the runserver run.

Any clue?

Daniele Procida

unread,
Oct 15, 2013, 11:11:36 AM10/15/13
to django-d...@googlegroups.com
On Tue, Oct 15, 2013, rok <spuz...@gmail.com> wrote:

>I have recently been testing the 1.6b4 tag with a new app we are
>writing, using apache and wsgi. However, I could not get rid of the
>following issue happening on every request:

You'll be better off asking this question over on the Django users email list, rather than here (this list is for the development of Django itself, rather than general usage or deployment questions).

You can sign up to the django-users list at <http://groups.google.com/group/django-users/>.

The #django IRC channel on IRC (on irc.freenode.net) is also very helpful.

Daniele

rok

unread,
Oct 15, 2013, 1:09:42 PM10/15/13
to django-d...@googlegroups.com
Thanks Daniele,

I thought since the 1.6 release is in the final stretch this might be somewhat related to bugfixing. I posted it to the users forum.

Rok

Daniele Procida

unread,
Oct 15, 2013, 1:26:45 PM10/15/13
to django-d...@googlegroups.com
On Tue, Oct 15, 2013, rok <spuz...@gmail.com> wrote:

>I thought since the 1.6 release is in the final stretch this might be
>somewhat related to bugfixing. I posted it to the users forum.

Well it could indeed be a bug of course. Is it feasible for your to reduce it to something easily reproducible?

Daniele

Russell Keith-Magee

unread,
Oct 15, 2013, 9:17:10 PM10/15/13
to Django Developers
Hi Rob,

If you're able to generate a cyclic import error in 1.6b4, then that's definitely a release blocker.

The first step is obviously to reproduce the bug. This isn't something I've seen in my testing, and that particular file (sites.py) hasn't changed in 5 months (at least, not in the 1.6 branch). Can you detail what you did to cause this bug to surface? 

Yours,
Russ Magee %-)


--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5fc43a85-0d0c-4c9f-baea-ac610a17ab68%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ivan Kharlamov

unread,
Oct 16, 2013, 3:26:33 AM10/16/13
to django-d...@googlegroups.com
Hi!
Well, if this doesn't happen in the dev environment and does happen in
production, is there any chance that you're using gunicorn via
`gunicorn_django` command? If yes, try running the project with
`gunicorn` command instead.

I have seen some weird import errors which occured only when I was
running the project with `gunicorn_django` in conjunction with Django
1.6, but I didn't take time to debug and report them since
`gunicorn_django` command is deprecated and switching to `gunicorn`
command fixed everything.

Regards,
Ivan

rok

unread,
Oct 17, 2013, 4:12:39 AM10/17/13
to django-d...@googlegroups.com
Hi everyone,

unfortunately I am not able to reproduce it from a "scratch-point", I am sorry.

Also, we are not using gunicorn, just apache+mod_wsgi.

I read somewhere that this could be related to the python path so I checked it in dev and production environments, and simply set the same path in dev by setting the sys.path=[the same list of paths as in dev] within the wsgi.py to try to eliminate this potential cause. Still, the problem persisted.

Rok

Marc Tamlyn

unread,
Oct 17, 2013, 4:19:54 AM10/17/13
to django-d...@googlegroups.com

Can you perhaps try it with a check out of Django and use git bisect to find the cause? That might give us an indication of how the code base has changed to break it for you. Without a means of reproduction it is hard for us to do anything.

Marc

Andrew Pashkin

unread,
Feb 10, 2014, 5:01:49 PM2/10/14
to django-d...@googlegroups.com
Got this while tried to laucnh Djangos test suite on fb1e3435a4d7e0265f19a1a9f130c9485fb8dfe9
Reply all
Reply to author
Forward
0 new messages