Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import error cannot import name execute_manager in windows environment

I'll get you up to speed. I'm trying to setup a windows dev environment. I've successfully installed python, django, and virtualenv + virtualenwrapper(windows-cmd installer)

workon env
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1,6,1, 'final',0)
>>> quit()

But when I run: python manage.py runserver from my cloned repository I get this error:

Traceback (most recent call last)"
File "manage.py", line 2, in (module)
from django.core.management import execute_manager
ImportError: cannot import name execute_manager

Both python and django are added to my system variable PATH:

...C:\Python27\;C:\Python27\Scripts\;C:\PYTHON27\DLLs\;C:\PYTHON27\LIB\;C:\Python27\Lib\site-packages\; 

I've also tried this with bash and powershell and I still get the same error.

Is this a virtualenv related issue? Django dependence issue? Yikes. How do I fix this problem? Help me Stackoverflow-kenobi your my only hope.

like image 749
Modelesq Avatar asked Jan 03 '14 14:01

Modelesq


2 Answers

execute_manager deprecated in Django 1.4 as part of the project layout refactor and was removed in 1.6 per the deprecation timeline: https://docs.djangoproject.com/en/1.4/internals/deprecation/#id3

To fix this error you should either install a compatible version of Django for the project or update the manage.py to new style which does not use execute_manager: https://docs.djangoproject.com/en/stable/releases/1.4/#updated-default-project-layout-and-manage-py Most likely if your manage.py is not compatible with 1.6 then neither is the rest of the project. You should find the appropriate Django version for the project.

like image 129
Mark Lavin Avatar answered Nov 20 '22 16:11

Mark Lavin


@Mark Lavin explained nicely what the error means and how it arises. I think I've just discovered why others may also get this error message so leaving it here for the record.

I'm assuming you're running this from within a virtual environment.

When starting a new Django project, if you run django-admin startproject <myproject>, you are invoking the global installation of Django. If, as in my case, it comes from a stale repo, it may be an old version - in my case:

>> django-admin --version
>> 1.3.1

If you want to run Django from within a virtual environment, then you need to invoke it with django-admin.py startproject <myproject>. This way, you get a Django project with the version corresponding to your local installation:

>> django-admin.py --version
>> 1.6.6
like image 34
Gabriel Avatar answered Nov 20 '22 16:11

Gabriel