Ubuntu Next Python2-python3 Edition coexistence, creating Django project problems

Source: Internet
Author: User
Tags install django pip install django

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.