How to solve SyntaxError on autogenerated manage.py?

前端 未结 30 1938
囚心锁ツ
囚心锁ツ 2020-11-28 08:24

I\'m following the Django tutorial https://docs.djangoproject.com/es/1.10/intro/tutorial01/

I\'ve created a \"mysite\" dummy project (my very first one) and try to

相关标签:
30条回答
  • 2020-11-28 08:43

    Make sure which python version you connect the django with (Make sure to activate the virtual env if you are using any).

    When you install django using just

    pip install django 
    

    then you have to run

    python manage.py startapp <yourApp name>
    

    else if you have used:

    pip3 install django
    

    then you have to run

    python3 manage.py startapp <yourapp name>
    

    Refer:

    0 讨论(0)
  • 2020-11-28 08:44

    For running Python version 3, you need to use python3 instead of python.

    So, the final command will be:

    python3 manage.py runserver
    
    0 讨论(0)
  • 2020-11-28 08:44

    You must activate virtual environment where you have installed django. Then run this command - python manage.py runserver

    0 讨论(0)
  • 2020-11-28 08:45

    you should activate your virtual environment . In terminal -> source env/bin/activate now there will be ----> (env) in your terminal displayed !

    now it will work -> runserver .

    No need to delete exc part !

    0 讨论(0)
  • 2020-11-28 08:45

    I was experiencing the same but this was solved by running with specific python 3.6 as below:

    python3.6 manage.py runserver
    
    0 讨论(0)
  • 2020-11-28 08:45

    It's best to create a virtual environment and run your Django code inside this virtual environment, this helps in not changing your existing environments. Here are the basic steps to start with the virtual environment and Django.

    1. Create a new Directory and cd into it.

      mkdir test , cd test

    2. Install and Create a Virtual environment.

      python3 -m pip install virtualenv virtualenv venv -p python3

    3. Activate Virtual Environment: source venv/bin/activate

    4. Install Django: pip install django

    5. Start a new project: django-admin startproject myproject

    6. cd to your project and Run Project:

      cd myproject , python manage.py runserver

    7. You can see your project here : http://127.0.0.1:8000/

    0 讨论(0)
提交回复
热议问题