5

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.

jonsca
  • 10,218
  • 26
  • 54
  • 62
Thomas Cox
  • 309
  • 4
  • 12
  • 1
    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 May 10 '12 at 13:02
  • @Thomas Cox Please format your question better. Can't distinguish between problem and your own wording. – Joseph Victor Zammit May 10 '12 at 13:03
  • 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 May 10 '12 at 14:51
  • 1
    What are the actual versions you are using? 'Latest' is useless. – Ethan Furman Sep 18 '12 at 15:39
  • 1
    Why so much downvotes on this question? – Nikolay Fominyh Sep 21 '12 at 13:41
  • This question probably had a lot of down-votes because, as @ChrisPratt said, saying "latest" version is very unhelpful. It also doesn't describe what's happened before, or even what the user is trying to do. – Stu Cox Sep 23 '12 at 23:10
  • It's also suspicious that it's the "latest" version, "Python 3", but the version being used is in the `./Python27/` folder – jsvk Sep 24 '12 at 02:58
  • jsvk: Django doesn't run on python 3 yet so he is correct, more or less. – Timmmm Sep 24 '12 at 11:30
  • Also, everyone complaining about his use of "latest". It clearly says Django 1.4 and Python 2.7 in the paths. – Timmmm Sep 24 '12 at 11:33

6 Answers6

10

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.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • Solved my problem as well. It also shows how bad is the error-information system of Django =/ – Anoyz Jun 02 '13 at 19:39
3

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.

Mu Mind
  • 10,935
  • 4
  • 38
  • 69
0

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.

Marcin
  • 48,559
  • 18
  • 128
  • 201
0

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.

John Fink
  • 313
  • 1
  • 4
0

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.

swang
  • 219
  • 1
  • 3
-1

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.

Stu Cox
  • 4,486
  • 2
  • 25
  • 28
  • As jsvk pointed out above, it looks like you *are* using Python 2.7 - but said you were using Python 3 in a comment. – Stu Cox Sep 24 '12 at 06:27