"Is there some .py file in your install directory that matches the
name of an app you have listed in installed apps?"

I think this was the problem. Thanks!!

On Jun 11, 11:37 am, Karen Tracey <[email protected]> wrote:
> On Fri, Jun 11, 2010 at 9:11 AM, Stodge <[email protected]> wrote:
> > I'm writing an install script that resides in django_project/install
> > and one of things it does, is programmatically run syncdb. My current
> > code for this is correct if I do:
>
> > cd ..
> > python
> > import os
> > os.environ["DJANGO_SETTINGS_MODULE"]="settings"
> > from django.core.management import call_command
> > call_command('syncdb', interactive=False)
>
> > If I copy this code into my installer, or indeed do the same as above,
> > but inside the django_project/install directory it fails:
>
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in <module>
> >  File "/usr/lib/python2.6/site-packages/django/core/management/
> > __init__.py", line 166, in call_command
> >    return klass.execute(*args, **defaults)
> >  File "/usr/lib/python2.6/site-packages/django/core/management/
> > base.py", line 221, in execute
> >    self.validate()
> >  File "/usr/lib/python2.6/site-packages/django/core/management/
> > base.py", line 249, in validate
> >    num_errors = get_validation_errors(s, app)
> >  File "/usr/lib/python2.6/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.6/site-packages/django/db/models/loading.py",
> > line 145, in get_app_errors
> >    self._populate()
> >  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> > line 60, in _populate
> >    self.load_app(app_name, True)
> >  File "/usr/lib/python2.6/site-packages/django/db/models/loading.py",
> > line 82, in load_app
> >    if not module_has_submodule(app_module, 'models'):
> >  File "/usr/lib/python2.6/site-packages/django/utils/
> > module_loading.py", line 14, in module_has_submodule
> >    for entry in package.__path__:  # No __path__, then not a package.
> > AttributeError: 'module' object has no attribute '__path__'
>
> > I've tried adding the project's path to sys.path, but that doesn't
> > make a difference. Is there a way to do this from a sub-directory?
>
> You need to ensure the python path in effect when this code runs from your
> installer is correct. Based on the error, it does not appear to be. The
> error implies that something listed in INSTALLED_APPS is being found, but it
> is not a package. Apparently what is being found when you run the code from
> the shell is different from what is being found when you run the code in the
> installer, and the likely cause of the difference is a different Python
> path.
>
> The first item in your PYTHONPATH will be the current directory. Is there
> some .py file in your install directory that matches the name of an app you
> have listed in installed apps? That could lead to this problem, if your
> installer code is running with a current directory of your install
> directory.
>
> Note there is a ticket open on this error situation 
> (http://code.djangoproject.com/ticket/13603). In older versions of Django
> this oddity of having a non-package listed in INSTALLED_APPS was just
> ignored. In your case I doubt the "fix" of simply ignoring whatever app is
> causing the problem would likely not be helpful, since I'm guessing some
> tables your installer should create would not be created. However the error
> message could be more helpful.
>
> Karen
> --http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to