5
votes

Using Window 7 64Bit with Python 2.7 and Django 1.4.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Django-1.4\django\bin\cms2>manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Traceback (most recent call last):
  File "C:\Django-1.4\django\bin\cms2\manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
443, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232,
 in execute
    output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 371,
 in handle
    return self.handle_noargs(**options)
  File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 164, in handle_noargs
    call_command('loaddata', 'initial_data', verbosity=verbosity, database=db)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
150, in call_command
    return klass.execute(*args, **defaults)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232,
 in execute
    output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.p
y", line 239, in handle
    (full_path, ''.join(traceback.format_exception(sys.exc_type,
UnboundLocalError: local variable 'full_path' referenced before assignment

Error

UnboundLocalError: local variable 'full_path' referenced before assignment

I installed it myself, but it is giving me errors. What is wrong with it? I tried to Google, but nothing came up.

6
I'll cut out the part where you are trying to find the right directory, It might be a little humorous, I don't think it's relevant. - Gareth Latty
@Thomas Cox Please format your question better. Can't distinguish between problem and your own wording. - Joseph Victor Zammit
Please actually give Python and Django versions. "Latest" won't mean much a year from now if someone is referring to this trying to solve there own problem. It doesn't mean much now, even, because you can either be running the "lastest" Python 2.x branch or the "latest" Python 3. - Chris Pratt
What are the actual versions you are using? 'Latest' is useless. - Ethan Furman
Why so much downvotes on this question? - Nikolay Fominyh

6 Answers

10
votes

I also had this problem. It was caused by (someone else) having added this to my settings.py:

SERIALIZATION_MODULES = {
    'json': 'wadofstuff.django.serializers.json'
}

And I didn't have that thing installed. You can install it using:

pip install wadofstuff-django-serializers

I imagine a similar error occurs for other missing software.

2
votes

This is yet another example of Django eating your original exception, doing the wrong thing, and giving you a completely uninformative error instead.

Looking at the flow of logic, you should be able to bypass this bug and see what your actual error is if you do

manage.py syncdb --traceback

or maybe

manage.py --traceback syncdb

That should answer this particular question and tell you what's going wrong inside of Django. Once you find that, I'd recommend posting that traceback in a new question if you still can't figure out what's going wrong.

0
votes

The problem is that windows does not know what to do with python files. Either change your windows settings, or explicitly invoke python: python manage.py.

0
votes

This seems to be a hole in Django 1.4.1. We don't have enough information to tell you exactly what is causing you to fall through this hole, but it looks like the latest git version does not have this hole. I think if you update to the latest repo code, you will not have this error.

I think you will also find out that something else is throwing an error to make this error possible.

0
votes

if you look into the code of loaddata.py, you can see that an exception must happened before full_path is assigned a value at line 163, that made exception handle raised another exception thus masked the actual error. What I suggest is to add "full_path = ''" at the beginning of the handle() function so you can at least see the real error.

-1
votes

Django 1.4 isn't compatible with Python 3.x.

It's probably worth trying again with Python 2.7 and seeing if you hit the same problem.