I am trying to install Django in linux version x86.I have already installed python. Error I am getting when executed "pip install Django" or "pip3 install Django"
$ pip install django
Traceback (most recent call last):
File "/home/mandar/.local/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/home/mandar/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
EDIT 2:
I suggest you to upgrade Python to a newer version as other user has adviced. This is because f-string was added form Python 3.6 on, check this.
Step 1:- Install ppa:
sudo add-apt-repository ppa:deadsnakes/ppa
Update packeges:
sudo apt-get update
Upgrade python 2.x to python 3.6 or higher
sudo apt-get install python3.6
PiP installation:
sudo apt install python3-pip
Upgrade pip first (which also upgrades setuptools) and then install django again:
pip install -U pip
pip install django
Or:
pip install --upgrade pip
pip install django
Alternative 2:
sudo python -m pip install --upgrade --force setuptools
sudo python -m pip install --upgrade --force pip
sudo pip install django==3.1
EDIT: As @Ronald Petit stated,keep this in mind:
Django 3.0+ requires python 3.6+ and you are using python 3.5, you need to either update to a newer python (recommended), or specify Django version to be 2.2 (really not recommended)
hence Run
pip install django==2.2
Django 3.0+ requires python 3.6+ and you are using python 3.5, you need to either update to a newer python (recommended), or specify Django version to be 2.2 (really not recommended)
To install an specific django version just do:
pip install django==x.x.x
x.x.x can be replaced for example with 2.2
docs: https://docs.djangoproject.com/en/3.1/faq/install/#faq-python-version-support
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With