1.python Introduction
Python founder: Guido van Rossum, hailed as a benevolent dictator in the Python world.
Borrowed from the Unix shell, C features
1989 Christmas period, Python has been 20 years of history, much earlier than Java, the first version of Java was released in 1994.
2000 10.16 Python2.0 Released, this time Python really become a fully functional, very useful language
December 3, 2008, Python3 released, compared with Python2, the change is relatively large, incompatible python2. Currently two versions coexist
Positioning of the 2.python:
interpreted generic language (operating system kernel, etc. without interpreter exists, cannot use Python on kernel or hardware)
Elegant, clear, simple, doing something in python with only one optimal solution
Scope of Use: web (domestic watercress, know-how, etc.), automated scripting, data analysis (native Python support on spark), etc.
Implementation and version of 3.python:
Generally speaking Python is developed by C language, is the official version
Jython is written by Java and runs on the JVM and can be seamlessly compatible with existing Java libraries
IronPython is run on the. NET platform, compatible with. NET libraries
PyPy is python written in Python (more widely used in scientific computing), there is a big "flaw" in Python, Gil Global Library interpreter lock, PyPy is to solve this problem exists.
No forward compatibility between large versions (Python3 and Python2)
4. Installing pyenv
The Python environment is already installed on most Linux, but the Python version of the different release Linux installations will be different, pyenv to manage multiple versions of Python.
We sometimes need to use multiple versions of Python in our work,
[[email protected] ~]# yum-y install gcc gcc-c++ make git patch openssl_devel zlib-devel readline-devel sqlite-devel bzip 2-devel
4.1 Installing the PYENV:
Here is a setup script that I learned from my teacher when I was learning Python, and downloaded it to run directly:
[Email protected] ~]# Https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer
[Email protected] ~]# sh pyenv-installer
4.2 Configuring Environment variables:
[Email protected] ~]# cat/etc/profile.d/pyenv.sh
Export path= "$HOME/.pyenv/bin: $PATH"
Eval "$ (pyenv init-)"
Eval "$ (pyenv virtualenv-init-)"
[Email protected] ~]#. /etc/profile
4.3 Installing python2.7.5 and 3.1 using pyenv
[Email protected] ~]# pyenv install 2.7.5
The python that comes with the system in #rhel7 and CentOS 7 is the 2.7.5 version
[[email protected] ~]# pyenv Install 3.1
# Install pypy-1.9
4.4 Tell pyenv which version of Python the current directory uses
[Email protected] python]# pyenv local 2.7.5
[[email protected] python]# pyenv rehash# rebuild environment variable, tell pyenv to use this version now
[Email protected] python]# pyenv version
2.7.5 (set By/root/python/.python-version)
# Other directories are still using the system's own version, this is the Linux 7, so it's all 2.7.5.
5. Open a Python shell:
[[email protected] ~]# python
Python 2.7.5 (default, Sep 20 2016, 19:47:46)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>>
6. Install Easy_install,
[Email protected] ~]# wget Https://bootstrap.pypa.io/ez_setup.py-O-| Python
Ipython is an enhancement to the Python shell (auto-complete, clearer view of the document, etc.):
[Email protected] ~]# Easy_install Ipython
Open the Ipython Shell:
[Email protected] ~]# Ipython
/ROOT/.PYENV/VERSIONS/2.7.5/LIB/PYTHON2.7/SITE-PACKAGES/IPYTHON-5.1.0-PY2.7.EGG/IPYTHON/PATHS.PY:54: Userwarning:moving ~/.config/ipython to ~/.ipython
Warn (' moving {0} to {1} '. Format (Cu (Xdg_ipdir), Cu (Ipdir)))
Python 2.7.5 (default, Sep 20 2016, 19:47:46)
Type "Copyright", "credits" or "license" for more information.
IPython 5.1.0--an enhanced Interactive Python.
? Introduction and overview of IPython ' s features.
%quickref, Quick Reference.
Help, Python ' s own Help system.
Object? Details about ' object ', use ' object? ' for extra details.
In [1]:
This article from the "Technology life, Simple not simple" blog, please be sure to keep this source http://willis.blog.51cto.com/11907152/1854701
Python Basics (1)--Introduction and installation