0
votes

I am trying to run a Django project that works fine on my collegue's machine, but I get an error from haystack when trying to runserver.

  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/base.py", line 280, in execute
    translation.activate('en-us')
  File "/usr/local/lib/python3.2/dist-packages/django/utils/translation/__init__.py", line 130, in activate
    return _trans.activate(language)
  File "/usr/local/lib/python3.2/dist-packages/django/utils/translation/trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "/usr/local/lib/python3.2/dist-packages/django/utils/translation/trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/usr/local/lib/python3.2/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "/usr/lib/python3.2/importlib/__init__.py", line 124, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 821, in _gcd_import
    loader.load_module(name)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 436, in load_module
    return self._load_module(fullname)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 141, in decorated
    return fxn(self, module, *args, **kwargs)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 342, in _load_module
    exec(code_object, module.__dict__)
  File "/usr/local/lib/python3.2/dist-packages/haystack/__init__.py", line 7, in <module>
    from haystack.utils import loading
  File "/usr/local/lib/python3.2/dist-packages/haystack/utils/__init__.py", line 28
    raise AttributeError(u"Provided string '%s' is not a valid identifier." % obj_or_string)
                                                                          ^
SyntaxError: invalid syntax

I have haystack included in your installed apps.

Linux ubuntu 3.5.0-44-generic #67-Ubuntu SMP Tue Nov 12 19:36:14 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Python 3.2.3

pip 6.0.8 from /usr/local/lib/python3.2/dist-packages (python 3.2)

Name: django-haystack
Version: 2.3.1
Location: /usr/local/lib/python3.2/dist-packages
Requires: Django

Any ideas are welcome

Thanks

1
Please could you paste the relevant part of your code? - br3w5
There aren't any changes to his code so I don't know what to post, and it looks like the error comes from haystack. - holmeswatson

1 Answers

1
votes

This appears to be a Python version issue. Python 3.2 does not have the u prefix for strings, because strings are unicode by default in Python 3. The prefix was reintroduced in Python 3.3 to make compatibility with 2.7 easier. See the 3.3 release notes.

Note that the PyPI page for Haystack 2.3.1 mentions 3.3+ as a requirement.

You should upgrade your Python version to 3.3.