MA1
MA1

Reputation: 33

New to Python - Django manage.py runserver invalid syntax

I'm setting up a new environment for a new project and I'm getting an SyntaxError: invalid syntax when running python manage.py runserver

Greater details

File "manage.py", line 16
) from exc
     ^

SyntaxError: invalid syntax

Manage.py

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'personal_portfolio.settings')
try:
    from django.core.management import execute_from_command_line
except ImportError as exc:
    raise ImportError(
        "Couldn't import Django. Are you sure it's installed and "
        "available on your PYTHONPATH environment variable? Did you "
        "forget to activate a virtual environment?"
    ) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()

Upvotes: 0

Views: 432

Answers (1)

lahsuk
lahsuk

Reputation: 1274

It's like @Michael Butscher said, you're running it with python 2.0 and that is what is giving the problem.

Try running it like python3 manage.py. When you have both python 2 and python 3 installed in your system, running python runs python2.

Hope that helps.

Upvotes: 1

Related Questions