python学习之一——开发环境准备

一、集成开发环境

Windows:

        Python + PyCharm

        Python + Eclipse + PyDev

Linux:

        Python + PyCharm

二、Python版本升级

在2.x版本中当前普遍使用的是2.7版本,如果系统自带的python版本比较低,需要对自带版本进行升级。(3.x版本的升级方法相同)

1、官网下载安装包:

[root@localhost ~]# cd /opt/src/

[root@localhost src]# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

2、编译安装

安装依赖包:openssl-devel、zlib-devel、readline-devel、sqlite-devel

[root@localhost src]# tar zxf Python-2.7.10.tgz
[root@localhost src]# cd Python-2.7.10
[root@localhost Python-2.7.10]# ./configure --prefix=/usr/local/python2.7.10
[root@localhost Python-2.7.10]# make && make install

3、修改当前python命令版本

       安装完成后,查看python版本:

            [root@localhost src]# python -V
            Python 2.6.6

        发现版本没有改变,这时需要创建软连接:

            [root@localhost ~]#rm -f /usr/bin/python

            [root@localhost ~]#ln -s /usr/local/python2.7.10/bin/python2.7 /usr/bin/python

        再次查看版本:

            [root@localhost ~]#python -V
            Python2.7.10

        升级版本后,由于yum只支持到python2.6,为了防止yum失效,需要修改/usr/bin/yum文件:

            [root@localhost ~]# vim /usr/bin/yum 

           第一行  #!/usr/bin/python修改为#!/usr/bin/python2.6即可

三、ipython安装

IPython是Python的交互式Shell,提供了代码自动补完,自动缩进,高亮显示,执行Shell命令等非常有用的特性。特别是它的代码补完功能,例如:在输入zlib.之后按下Tab键,IPython会列出zlib模块下所有的属性、方法和类。完全可以取代自带的bash

yum安装:

2版本的ipython只需要安装epel源然后yum直接安装就可,不需要手动安装:
[root@localhost ~]#yum install epel-release -y
[root@localhost ~]#yum install ipython -y
安装完之后运行ipython:

[root@localhost ~]# ipython
Python 2.7.5 (default, Apr 11 2018, 07:36:10) 
Type "copyright", "credits" or "license" for more information.

IPython 3.2.1 -- 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]: 


3版本的ipython3安装只需要使用python3用下面命令安装即可
[root@wing ~]# python3 -m pip install ipython

安装完运行ipython3:
[root@wing ~]# ipython3
Python 3.6.2 (default, Sep 14 2017, 15:13:07)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章