First, the Python installation preparation Python
Dutch Guido van Rossum,2005 joins Dropbox for google,2013 year
1989, the creation of the Python language, in early 1991 released the first public release version
Python philosophy
>>> Import this
The Zen of Python
2.x and 3.x differences
Statement is functional, such as print 1 2, but 2.x means print statement printing tuple, 3.x meaning is a function of 2 parameters
Divisible, for example 1/2 and 1//2,3.x versions/for natural divide
Raw_input renamed as input in 3.x, no longer using raw_input
Round function, the rounding of I.5 in 3.x becomes the nearest even
Unicode for uniform use of strings
Exception capture, thrown syntax change
Python environment to build development environment-PYENV
Python Multi-version management tool
Managing the Python Interpreter
Managing Python Multiple Versions
Managing a Python virtual environment
Official website Https://github.com/pyenv/pyenv
Windows not supported, reason HTTPS://GITHUB.COM/PYENV/PYENV/ISSUES/62
Linux System Preparation
Prepare the Linux minimum system.
If you clone in a virtual machine, the MAC address will change.
Use CentOS 6.5+ here
Note Several questions:
The network adapter in the virtual machine is recommended to use NAT mode, and the future Python program deployment requires an extranet connection
/etc/sysconfig/network-scripts/ifcfg-eth0
Bootproto=static,
IP address ipaddr=
Mask netmask=
Gateway Geteway=
Onboot=yes
Rm-rf/etc/udev/rules.d/70-persistent-net.rules, delete this file
Servece iptables Stop shutting down the firewall
Vi/etc/sysconfig/selinux Setting Parameters selinux=disabled
Restart the machine and make a snapshot
Yum Install git-y git
Yum-y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-
Devel installing Python compilation dependencies
Create user Python
# Useradd Python
# echo Python | passwd python--stdin
PYENV official website Https://github.com/pyenv/pyenv
Pyenv-installer plug-in Https://github.com/pyenv/pyenv-installer
Curl-l Https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | Bash
Attention:
1. Installation documentation in Https://github.com/pyenv/pyenv-installer
2. If Curl appears curl: (+) SSL Connect error, is the issue of low NSS version, update it. The current NSS version is only 3.15.
You may need to configure a Yum source with a newer package, and the etc/yum.repo.d/file ends with a. Repo:
[Updates]
Name=centos-updates
baseurl=https://mirrors.aliyun.com/centos/6/os/x86_64/
Gpgcheck=0
Update Yum Update NSS
Append to Python user's ~/.bash_profile
Export path= "/home/python/.pyenv/bin: $PATH"
Eval "$ (pyenv init-)"
Eval "$ (pyenv virtualenv-init-)"
$ source ~/.bash_profile
When the user starts, the script in the user's. Bash_profile is executed and the pyenv is started.
The installed pyenv is in the ~/.pyenv directory.
Pyenv Install--list list available versions
Pyenv Install 3.6.6 installation 3.6. Version 6
PYENV versions viewing installed versions
Such installation may be slow, in order to speed up, but choose the cache method.
Install using cache mode
In the ~/.pyenv directory, create a new cache directory and put the downloaded file to the installed version.
Not sure which file to take, the downloaded XZ, GZ, tgz These files are placed in the cache directory.
$ pyenv Install 3.5.3-v
Pyenv Global 3.5.5
Pyenv the Python version of the local 3.5.3 inheritance setting
Pyenv Shell 3.5.3
Pyenv Local--unset
VIRTUALENV Virtual Environment settings
Why use a virtual environment?
Because the Python environment you just used is a public space, if multiple projects are developed using a different Python version, or using a different
Python versions are deployed, or are developed using the same version, but different projects use different versions of the library, and so on, these problems will bring
Process. The best solution is for each project to run its own "isolated small environment" independently of each other.
Using plugins, in plugins/pyenv-virtualenv
$ pyenv virtualenv 3.5.3 mag353
Create a separate virtual space using the Python 3.5.3 version.
$ pyenv Versions
* System (Set By/home/python/.pyenv/version)
3.5.3
3.5.3/envs/mag353
mag353
Can be displayed in the version list, and 3.5.3 is the same, is a version of the.
The real directory under ~/.pyenv/versions/, as long as the use of this virtual version, the package will follow the corresponding directory down, instead of using 3.5.3
Pip is Python's package management tool, 3.x version directly with, can be used directly.
As with Yum in order to use the domestic image, the following configuration.
$ mkdir ~/.pip
Configuration file in ~/.pip/pip.conf
[Global]
index-url=https://mirrors.aliyun.com/pypi/simple/
Trusted-host=mirrors.aliyun.com
Windows system
The configuration file for the PIP under Windows is ~/pip/pip.ini, as in the following
Home directory for Windows, type "." In "Run".
PIP Package Manager
Pip Install XXX yyy
PIP List
PIP Search keyword or pypi
Pip Help Install
PIP configuration
$ vim ~/.pip/pip.conf
[Global]
Index-url=http://mirrors.aliyun.com/pypi/simple
Trusted-host=mirrors.aliyun.com
The domestic source of Tsinghua and watercress
PIP Package Manager
Pip Install Redis Ipython
Pip Install Jupyter
Pip-v
PIP Freeze > Requirement
PIP Install-r Requirement
IPython Jupyter
IPython
Enhanced Python shell, auto-complete, auto-indent, support Shell, add a lot of functions
Jupyter
Jupyter Notebook Password
Jupyter Notebook--ip=192.168.1.30--port=8888
It is independent of the project from the Ipython
Stand-alone interactive notebooks with Ipython in the background
Shortcut keys: Shift + ENTER, Ctrl + ENTER, DD, M
Pycharm
https://www.jetbrains.com/pycharm/
Build projects, write code, run
Python Installation Preparation