Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django manage.py runserver invalid syntax

Tags:

python

django

I am developing a web in Ubuntu using django. Everything works normal. Now, I want to change my computer which use Windows. When I try to runserver, it gives:

E:\DEGNet>py manage.py runserver
  File "manage.py", line 14
    ) from exc
         ^
SyntaxError: invalid syntax

E:\DEGNet>py
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

As shown above, I have installed Python 3.6.3. I have installed django and other necessary library using pip3 too.

Edit: manage.py file, it is a default manage.py that I get when generating the project.

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DEGNet.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)
like image 959
Bharata Avatar asked Dec 19 '17 05:12

Bharata


People also ask

Why does Python manage PY Runserver not work?

The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

Can't open file manage PY No such file or directory?

This is the common error in django as you could see on your screen like that.. This error is coming because we are not in the folder where manage.py is located so, we have to go in that folder where manage.py has been located.


1 Answers

I faced same problem but now solved with this cmd:

python3 manage.py runserver
like image 52
suria sarath Avatar answered Sep 28 '22 05:09

suria sarath