0

I'm just getting started with CS50 Web's problem 1 (wiki). I've got the code and I'm trying to run the Django server for the first time to see what the source code gives me.

I have made no edits to the source code.

I am running python manage.py runserver

When I do this I get the error message

File "manage.py", line 16 ) from exc ^ SyntaxError: invalid syntax

Lines 7-17 of manage.py are:

    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wiki.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)

But, when I run python3 manage.py runserver it works fine.

What is the syntax difference between the python versions that is causing the error?

1
  • Does using python manage.py shell give any problems?
    – Vsjain
    Commented Apr 15, 2021 at 5:24

1 Answer 1

0

python in the IDE is a link to python2.

~/ $ which python
/usr/bin/python
~/ $ ls -al /usr/bin/python
lrwxrwxrwx 1 root root 7 Apr 15  2020 /usr/bin/python -> python2*

The raise statement in python2 does not have a from clause.

1
  • Thank you, this is great!
    – David S
    Commented Apr 18, 2021 at 2:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .