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.
Django Getting Started: 1_Environment Building Django Getting Started: 2_Project Creation Beginning with Django: 3_Apache integration Beginning with Django: 4_MySQL integration
The following environment is built with Vagrant. I would like to summarize the virtual environment construction in the near future.
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.
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)
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.
[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