python interpreter to install and use (windows, and linux version)

The basic concept python

python is a programming language, different languages ​​with shell, shell is a scripting language

python is a high-level language,

Said here about the high-level language is not "big on" the kind of meaning

But

越接近人类的语言,越高级 如python,java语言,但执行效率低,比较容易掌握

越低(底层)的语言,执行效率越高 如 c ,c++语言,比较难掌握

install windows platform python

官网是如下
www.python.org

学习使用3.5版本的,去下载对应包即可,注意2版本的与3版本有不少区别,不要下错了

64 should be below
Here Insert Picture Description
double-click to install, as shown in a note to check, or will be error
Here Insert Picture Description
Wait for the installation, but do not click cancel to exit meant that

The installation is complete, close Exit

验证安装,打开cmd命令行,输入python出现如下成功
Here Insert Picture Description
Of course, so inconvenient to use python, here using python interpreter

python interpreter uses

In the "Start menu" search "python", a IDLE (Python 3.5 64-bit)" ", click on

Enter the following chart, which is a standard interpreter
Here Insert Picture Description
in this way is to click Enter to execute one line of code, very convenient, so we generally use the following way

Here Insert Picture Description

Will open a blank page, multi-line coding
After, for example, as shown below, enter the code, press "f5",

点击确定,第一次要求选择保存位置,

Here Insert Picture Description
Choose the location, and custom name

Then automatically in the interpreter, the output content codes as

Here Insert Picture Description

Press the "f5" you can directly run the code content of
Further font size, font type, and in the following figure tone

Here Insert Picture Description
Pop up, according to my next chart you can modify the
Here Insert Picture Description

Installation on the Linux

Linux version comes Python2.6.6
tar package installation Python3.5.4 version

3.5.4的安装包百度云,如下

Links: https://pan.baidu.com/s/1AIodsUN_e6V303IxhOtXlQ
extraction code:ffum

1) dependent on the installation environment necessary python

Mounting system disc, arranged yum source
[CentOS7-02 the root @ ~] # yum the install Python -Y-devel OpenSSL-devel zlib bzip2-devel-devel expat-devel SQLite the ncurses-devel-gdbm-devel devel tk- an xz-devel devel readline-devel gcc

[root@CentOS7-02 ~]# yum -y groupinstall "Development tools"

2) tar package installation python3.5.4

[CentOS7-02 the root @ ~] # CD / usr / local / (put packets transmitted to the path)
the Python-3.5.4holder into
[the root @ CentOS7-02 local] # LS | grep the Python-3.5.4
Python-3.5.4.tgz

[root@CentOS7-02 local]# tar zxf Python-3.5.4.tgz
[root@CentOS7-02 local]# cd Python-3.5.4

检测环境中依赖是否完整,设置python的安装位置, 同时生成一个编译文件Makefile,用于进行python编译
[root@CentOS7-02 Python-3.5.4]# ./configure --prefix=/usr/local/python3 --enable-optimizations
[root@CentOS7-02 Python-3.5.4]# make && make install
(时间会比较长,请耐心等待)

3) The default setting python3 interpreter python

[root @ CentOS7-02 Python 3.5.4] # cd / usr / bin /
[root @ CentOS7-02 bin] # mkdir behind
[root @ CentOS7-02 bin] # mv python behind /

python3 executable file, make a link, set as the default interpreter
[root @ CentOS7-02 bin] # LN -s / usr / local / python3 / bin / python3 / usr / bin / Python

4) Since a yum python2 compiler implementation, it is necessary to set separate python2 yum

[root@CentOS7-02 bin]# vim /usr/bin/yum
进入后修改第一行,改成如下图
Here Insert Picture Description

5) Add the environment variable pip

pip is a Python package manager. This means that it is a tool that allows you to install and manage and do not belong to other libraries rely on standard libraries.
[root @ CentOS7-02 bin] # LN -s / usr / local / python3 / bin / PIP3 / usr / bin / PIP3

6) Update pip: the need for network

[root@CentOS7-02 bin]# pip3 install --upgrade pip

7) Use python3

[root@CentOS7-02 ~]# cd /root/
[root@CentOS7-02 ~]# vim 1.py
#!/usr/bin/python
x=1
print (x)

[root@CentOS7-02 ~]# python 1.py
1

It has been successful, because python3 print variables, you must add (), not without prints
and python2, you can not add ()

Experiment is completed!

Published 54 original articles · won praise 57 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_45308292/article/details/103398011