Django Getting Started: 1_Environment Building

Introduction

I started to touch the Python framework Django, but I had some troubles and messed up, so I will write it to organize it. Please point out any mistakes.

This time I will describe the environment construction that I did.

The author's experience points are as follows.

So far, I've mainly touched PHP, and the framework used Laravel.

table of contents

Django Getting Started: 1_Environment Building Django Getting Started: 2_Project Creation Beginning with Django: 3_Apache integration Beginning with Django: 4_MySQL integration

environment

The following environment is built with Vagrant. I would like to summarize the virtual environment construction in the near future.

Pyenv installation

First, Python has Python 3 and Python 2. Some are not compatible. Therefore, it is necessary to switch the Python version for each project.

If you reinstall it one by one, it will be troublesome and unavoidable. So we use the version control tool Pyenv.

You can specify the Python version to use for each directory. It's convenient. There is no doubt that when I actually thought about using Python for the first time, I had a hard time switching between the system default Python 2 and the installed Python 3.

I will go roughly.

cd /usr/local/bin
git clone git://github.com/yyuu/pyenv.git ./pyenv
echo 'export PYENV_ROOT="/usr/local/bin/pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
pyenv --version
pyenv 1.0.7-12-g235eea3

Download the source with git and give it through the path. If you can confirm the version at the end, you can use it properly.

anaconda installation

With pyenv, you can get not only various Python versions but also a Python environment that includes a set of libraries. Anaconda seems to contain a typical Python library. I added this because I want to use it for machine learning later. For now, the true value is unknown.

First, check the version of anaconda that can be installed with pyenv. pyenv install --list | grep anaconda

A lot will come out roughly, so copy and install the version you like.

pyenv install anaconda3-4.3.0
pyenv rehash
pyenv global anaconda3-4.3.0

Declare to use this python if you type the python command in all directories with pyenv global. Make sure anaconda is set.

pyenv version
anaconda3-4.3.0 (set by /usr/local/bin/pyenv/version)

By the way, you can also check here.

python -V
Python 3.5.2 :: Anaconda custom (x86_64)

Django installation

Now install it so that you can use django. Pip is used for Python package management, but if you are using anaconda, you can also manage packages with the conda command. You can install it with pip, but I will use conda because it is a big deal. Well, packages that can't be installed with conda will be installed with pip after all, so I'm not sure if it makes sense to use them properly.

conda install -c https://conda.anaconda.org/anaconda django

Make sure you have django installed.

python -m django --version
1.10.5

You are now ready to use Django. Next time I'll launch a Django project.

Reference URL

[Building a python environment using CentOS7 pyenv](http://blog.umentu.work/centos7-pyenv%E3%82%92%E5%88%A9%E7%94%A8%E3%81%97%E3 % 81% 9Fpython% E7% 92% B0% E5% A2% 83% E6% A7% 8B% E7% AF% 89 /) Python environment construction for those who aim to be a data scientist 2016

Recommended Posts

Django Getting Started: 1_Environment Building
Getting Started with Django 1
Getting Started with Django 2
Django Getting Started: 2_ Project Creation
Getting Started with Python Django (1)
Django Getting Started: 4_MySQL Integration
Django Getting Started: 3_Apache integration
Getting Started with Python Django (4)
Getting Started with Python Django (3)
Getting Started with Python Django (6)
Getting Started with Django with PyCharm
Getting Started with Python Django (5)
Django beginners tried building an environment
Django Crispy Tutorial (Environment Building on Mac)
Django environment construction
Building a Windows 7 environment for getting started with machine learning with Python
django environment construction
Grails getting started
Django Getting Started Part 2 with eclipse Plugin (PyDev)
Django Getting Started Part 3 about Python3 & MySQL Connector
Django 1.11 started with Python3.6
Getting started with Android!
Django project environment construction
1.1 Getting Started with Python
Getting Started with Golang 2
Getting started with apache2
Getting Started with Golang 1
Getting Started with Python
Getting Started with Optimization
Getting Started with Golang 3
Getting Started with Numpy
Getting started with Spark
Getting Started with Python
Getting Started with Pydantic
Getting Started with Golang 4
Getting Started with Jython
[Memo] Django development environment
Translate Getting Started With TensorFlow
Getting Started with Python Functions
Getting Started with Tkinter 2: Buttons
Get started with Django! ~ Tutorial ⑤ ~
Getting Started with Go Assembly
[Linux] [Initial Settings] Getting Started
Getting Started with PKI with Golang ―― 4
Django development environment construction memo
Get started with Django! ~ Tutorial ④ ~
Docker + Django + React environment construction
Getting started and using sample class-based generic views in Django
Get started with Django! ~ Tutorial ⑥ ~
Django environment development on Windows 10
Building a Python virtual environment
(Note) Django in Vagrant environment
django project development environment construction
Building a Python virtual environment
Python3 | Getting Started with numpy
Getting Started with Heroku-Viewing Hello World in Python Django with Raspberry PI 3
Learn how to use Docker through building a Django + MySQL environment
Building a kubernetes environment with ansible 2
Building a Python environment on Mac
Getting Started with Python responder v2
Get started with Python! ~ ① Environment construction ~