Jon
Jon

Reputation: 3194

Start Django Project Invalid Syntax

I am trying to create a new Django project but running

django-admin startproject myproject

gives the error

Traceback (most recent call last):
    File "/usr/bin/django-admin", line 7, in <module>
      from django.core.management import execute_from_command_line
    File "/usr/lib64/python2.6/site-packages/django/core/management/__init__.py", line 68
      commands = {name: 'django.core' for name in find_commands(__path__[0])}
                                  ^
SyntaxError: invalid syntax

I must be missing some libraries or some paths could be invalid. However, I am yet to find a solution.

My Django files are located here:

/opt/.virtualenvs/smart/lib/python2.7/site-packages/django/

Upvotes: 2

Views: 2155

Answers (1)

alecxe
alecxe

Reputation: 473753

You are using your system python to start a project which is Python2.6. And you've installed Django 1.7 into your Python 2.6 environment, but Django 1.7 dropped support for Python 2.6:

Django 1.7 requires Python 2.7 or above, though we highly recommend the latest minor release. Support for Python 2.6 has been dropped and support for Python 3.4 has been added.

In particular, the error you see is because of the dictionary comprehension syntax which was introduced in Python 2.7.

Upvotes: 2

Related Questions