Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 2.1 startproject throws weird error

I am trying to start my first app in Django 2.1 on Python 3.4. It's the first time with this versions, previously I worked only with Django 1.10 and Python 2.7. Everything on Ubunutu 14.04

I created a virtualenv, mostly following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04

However with slight changes of my own because first a locale issue appeared and was fixed like this:

sudo locale-gen "en_US.UTF-8"

Afterwards I changed the aliases like this:

alias python=python3
alias pip=pip3

That's all. After installing django==2.1 and runing:

django-admin.py start project myproject

This error appeared:

Traceback (most recent call last):
    File "/home/ubuntu/workspace/skw/bin/django-admin", line 7, in <module>
        from django.core.management import execute_from_command_line
    File "/home/ubuntu/workspace/skw/lib/python3.4/site-packages/django/core/management/__init__.py", line 11, in <module>
        from django.conf import settings
    File "/home/ubuntu/workspace/skw/lib/python3.4/site-packages/django/conf/__init__.py", line 18, in <module>
        from django.utils.functional import LazyObject, empty
    File "/home/ubuntu/workspace/skw/lib/python3.4/site-packages/django/utils/functional.py", line 12
        return _curried_func(*args, *moreargs, **{**kwargs, **morekwargs})
                            ^

Inside this file functional.py in django my lint is showing a syntax error exactly at the line 12 ... but not sure if that's relevant, since I didn't change the syntax to python3 yet.

Because of this I can not start a new project, how to solve this?

EDIT: It seems like it would run in Python2 not 3. However when I tried this:

python3 path/bin/django-admin.py startproject myproject

The result was exactly the same. I also did this with python3.4, still the same. Meanwhile it's been couple of hours and around 6 workspaces created and deleted. This probably is something basic that I am too tired to see but what?

python -V
Python 3.4.3

python3 -V 
Python 3.4.3

python3.4 -V
Python 3.4.3

When looking into python-v, django import work no problem.

like image 349
Stefan Avatar asked Dec 16 '25 19:12

Stefan


2 Answers

Django 2.1 is not supported on Python 3.4 - only 3.5, 3.6, and 3.7.

Release notes: https://docs.djangoproject.com/en/2.1/releases/2.1/

like image 74
Dashdrum Avatar answered Dec 19 '25 10:12

Dashdrum


The python version you use is 3.4.3. But django==2.1 will install Django 2.1.

Django 2.1 supports Python 3.5, 3.6, and 3.7. Django 2.0 is the last version to support Python 3.4. We highly recommend and only officially support the latest release of each series.

Source Django 2.1 release notes

So, You need to install to resolve it

pip3 install Django==2.0.0

like image 39
Sridhar Avatar answered Dec 19 '25 09:12

Sridhar