pythonpython-3.xdjangoubuntu-20.04django-shell

starting Django shell but python interpreter kicks off


I started the Django's shell using:

python3 manage.py shell

but weirdly the python interpreter is kicking off instead (I see >>> instead of [n]:, and the initializing text contains no Django information, besides the main imports for the shell aren't executed)

considering that: I'm in ubuntu 20.04, It was running with no problem with python instead of python3, now python isn't recognized but it's linked to python3 so no difference "isn't it??!".


Solution

  • Such problems can appear if you're using global python installation instead of virtual enviroments. It's better to create a virtual enviroment.

    sudo apt install -y python3-venv
    

    Then cd to your project directory and execute:

    python3 -m venv env
    source venv/bin/activate
    

    Then install your requirements and start django shell as usual, by executing

    python manage.py shell