linux installation configuration python django environment and the virtual environment and downloads

Python -related projects Environment Introduction

python3.6, pip download instructions frameworks (Django related data analysis related to the associated crawler ...)

djnago publishing environment! uwsgi + nginx

Database-related: sqlite3, mysql, redis ....

 

 

1. Python basic environment installation

Linux system comes with Python, Version: 2.7 daily project development requires version 3.6 and above!

Install Python before detection is installed

# 1. Check whether to install Python

python -V # detect python version

# 2. Which lookup instruction corresponding position command which python

# Result: / usr / bin / python

# 3. Go to / usr / bin directory to see all relevant directives python

cd /usr/bin/

-at * ls python

# Result: python ---> python2 ---> python2.7

 

 

Install Python are two ways of installing Python, before installation, must determine what kind of

Scheme 1:

Change the python command of soft links point to the new Python version python3.6 original python2.7 can not use!

Program 2:

New python3 instruction , soft links implementation of the new Python version python3.6 recommended! [Curriculum adopted!]

 

# 1. Installation Development Kit and its dependencies

yum -y groupinstall "Development tools"

 

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel

sqlitdevele

 

 

# 2. Upload Python3.6 archive to the / user / local, decompression

 cd /usr/local

 tar -zxvf Python-3.6.6.tgz

 cd Python-3.6.6

# 3. Compile install

 ./configure --prefix=/usr/local/python3

# 4. Installation make && make install> setup log file name .log

 make

 make install > py36.log

# 5. lib directory to write the configuration file

 echo "/usr/local/python3/lib" >> /etc/ld.so.conf

 ldconfig

6. # build Python3 command of soft link

ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

# 7 whether the test was successful

 python3 -V

 which python3

 cd /usr/bin

 -at * ls python

 cd /usr/local/

 

pip New soft links

# Pip build flexible connections

ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3

# Pip test version

PIP3 -V

pip3 list # prompt version is too low [Note: pip list possible error!]

# Update pip

pip3 install --upgrade pip

 

 

 

Virtual environment virtualenv virtual machine environment software, you can separate out a lot of space to run independently of each other relative to the frame to avoid version conflicts in general:! 1 corresponds to a virtual environment projects!

Ready virtual environment directory and directory publishing project

cd / mkdir data # New Data directory (saving user data related to the project)

cd data mikdir env #env directory is the directory virtual environment

mkdir wwwroot # wwwroot publish the root directory of the project

 

Virtual Environment

# 1. Download

pip3 install virtualenv

# 2. Build soft link

ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv

# 3. Create a virtual environment

cd /data/env

virtualenv --python = / usr / bin / python3 myproject # virtual environment name

# 4 activation

cd /data/env/myproject/bin

source activate # activate exit deactivate

# The current virtual environment software installation

pip install django == 2.1.7 (not installed django2.0)

 Welcome to public concern number simply pass on AI platform

Guess you like

Origin www.cnblogs.com/pythonyeyu/p/10980194.html