Step-by-step learning python development-mac build Python-django Environment

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

First determine which version to study, in the previous contact with Python, the python2.x version still occupies a large market. But as a beginner I decided to learn a new version, I believe the future will gradually turn to the 3.x version.

Actually building Python is not a very difficult thing, but the construction process will be some details, write down the memo.

1. Download and install Python, you can go to the official website to download the latest version of https://www.python.org/downloads/mac-osx/, I downloaded the 3.4.3. Installation is a fool-like, not much to say.

2. The installation is complete, but you will find that the Python version is still available on your Mac, but you'll see if it comes in Python 2.7. So how to change to the latest version:

    • Check the current Python command location: Whereis python, mine is/usr/bin/python.
    • Back up the current python:mv/usr/bin/python/usr/bin/python_default_backup (may require Administrator privileges sudo) so that this version is not executed by default when Python is executed
    • Find the installation location for the new installed version of Python, by default the new version of/usr/local/bin/is usually the same as the previous version of the Python location. You can check the Ls-al <python command location to see the soft connection pointing to location > to determine.
    • Set the new version to the default version under/usr/bin/to set a new version of soft connect ln-s/usr/local/bin/python3.4/usr/bin/python

3. The following is the installation of Django, it is recommended to use PIP installation, Python 3.4 is installed by default PIP (Pip Install Django). Of course you also go to the official download of the latest Django version.

4. Review the Django version and execute the following command sequentially

Python

>>> Import Django

>>> print (Django.get_version ())

My result is 1.8.4.

5. Create a Django project, according to the official documentation, you can execute django-admin startproject < website name, and this completes the project creation. Note that in some previous versions, the project was created using django-admin.py in Python. I had a hard time studying this before I created it.

6. Review the Django project directory you created, and if your computer supports the tree command, you can use tree. Default Mac is not installed, you can use DU-A instead, after all, not very important operation.

7. Run your website, Python manage.py runnserver, you can visit the URL 127.0.0.1:8000 to see the effect, although there are many questions, but here you have successfully established a Django Site foundation.

Step-by-step learning python development-mac build Python-django Environment

Related Article

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.