I am trying to install django 1.9 in my Ubuntu Box (14.04 LTS) with virtualenv enabled. but I got this wired installation problem.
(venv)nix1947$ pip install django
Downloading/unpacking django
Downloading Django-1.9-py2.py3-none-any.whl (6.6MB): 6.6MB downloaded
Installing collected packages: django
*** Error compiling '/home/nix1947/projects/newsportal/venv/build/django/django/conf/app_template/apps.py'...
File "/home/nix1947/projects/newsportal/venv/build/django/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
*** Error compiling '/home/nix1947/projects/newsportal/venv/build/django/django/conf/app_template/models.py'...
File "/home/nix1947/projects/newsportal/venv/build/django/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
Successfully installed django
Cleaning up...
Is this the problem in django source code ? or am I missing something ?
the python that I have used is python3 in virtualenv which is enabled by
virtualenv -p /usr/bin/python3 venv
command and the version of pip that I am using is
pip 1.5.4 from /home/nix1947/projects/newsportal/venv/lib/python3.4/site-packages (python 3.4)
and virtualenv version is
(venv)nix1947$ virtualenv --version
1.11.4
What is the problem, Can someone guide me
This is a common issue caused by an outdated version of setuptools (5.5.x):
When installing Django 1.9+ with setuptools 5.5.x, you’ll see:
Compiling django/conf/app_template/apps.py ... File "django/conf/app_template/apps.py", line 4 class {{ camel_case_app_name }}Config(AppConfig): ^ SyntaxError: invalid syntax Compiling django/conf/app_template/models.py ... File "django/conf/app_template/models.py", line 1 {{ unicode_literals }}from django.db import models ^ SyntaxError: invalid syntax
It’s safe to ignore these errors (Django will still install just fine), but you can avoid them by upgrading setuptools to a more recent version. If you’re using pip, you can upgrade pip using pip install -U pip which will also upgrade setuptools.
(Source: https://docs.djangoproject.com/en/1.9/releases/1.9/#syntaxerror-when-installing-django-setuptools-5-5-x)
The solution is to upgrade pip first (which also upgrades setuptools) and then install django again:
pip install -U pip
pip install django
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