Ubuntu system: Presence of python2.7.14 and python3.6.3
This is the time to install and use Django, and you can use the PIP command to install Django separately (if you have already installed PIP).
Python2: sudo pip install Django
Python3: sudo pip3 install Django
To create a Django project:
Django-admin. py Startproject HelloWorld
There may be a problem: django-admin.py not found, no orders.
This is required in the installation of Python-django, using the command: sudo apt intall python-django
After execution, you can create a Django project.
Problem: The Django project you created uses Python2 by default, which is if you use Python3 to run the project: Python3 manage.py runserver 0.0.0.0:8000, you will get an error, using Python2 will not
(If you need to create and run a Django project using Python3, you need to modify the Python version specified when Django was created)
Workaround: To view the Django installation path: which django-admin------> (mine is:/usr/bin/django-admin)
Open with Vim: vim/usr/bin/django-admin you will find that the first line of code is the path to the specified Python version, which is python2 by default and modified to Python3 installed path.
"To view the installation path for the Python version:
Python2:which python
Python3:which Python3
】
Creating a Django project like this is the specified Pyton version is Python3. Run a Django project with a command without an error: Python3 manage.py runserver 0.0.0.0:8000
Ubuntu Next Python2-python3 Edition coexistence, creating Django project problems