美文网首页
Centos中的Python编程工具

Centos中的Python编程工具

作者: 南天E心 | 来源:发表于2017-12-26 21:36 被阅读0次

    推荐两款在CentOS中进行Python编程用的工具IPython和Sublime text,IPython适合新手初学时使用,Sublime text适合有经验的人员使用。

    一、推荐使用ipython解释器

    1、Centos下安装pip

    1)首先安装epel扩展源:

    
    [root@www ~]# yum -y install epel-release
    
    

    2)更新完成之后,就可安装pip:

    
    [root@www ~]# yum -y install python-pip
    
    

    3)安装完成之后清除cache:

    
    [root@www ~]# yum clean all
    
    

    4)对pip进行升级

    
    [root@www ~]# pip install --upgrade pip
    
    

    2、安装IPython

    1)使用pip命令安装IPython

    
    [root@www ~]# pip install ipython
    
    

    使用pip命令安装IPython时经常会出错,当Python版本等于或低于2.7.x时提示不能安装IPython的最新版本6.0+,可以安装5.X版本

    
        Complete output from command python setup.py egg_info:
    
        IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
    
        When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
    
        Beginning with IPython 6.0, Python 3.3 and above is required.
    
        See IPython `README.rst` file for more information:
    
            https://github.com/ipython/ipython/blob/master/README.rst
    
        Python sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0) detected
    
    .    Your pip version is out of date, please install pip >= 9.0.1\. pip 8.1.2 detected.
    
        ----------------------------------------
    
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-RknuFG/ipython/
    
    

    2)解决方法:使用指定版本安装IPython

    
    [root@www ~]# pip install ipython==8888
    
    

    先输入一个不存在的版本号,如:8888,可以显示能够安装的版本

    
    [root@www ~]# Collecting ipython==8888
    
      Could not find a version that satisfies the requirement ipython==8888 (from versions: 0.10, 0.
    
    10.1, 0.10.2, 0.11, 0.12, 0.12.1, 0.13, 0.13.1, 0.13.2, 1.0.0, 1.1.0, 1.2.0, 1.2.1,
    
    2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 3.0.0, 3.1.0, 3.2.0, 3.2.1, 3.2.2,
    
    3.2.3, 4.0.0b1, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.1.0rc1, 4.1.0rc2, 4.1.0, 4.1.1, 4.1.2,
    
    4.2.0, 4.2.1, 5.0.0b1, 5.0.0b2, 5.0.0b3, 5.0.0b4, 5.0.0rc1, 5.0.0, 5.1.0, 5.2.0,
    
    5.2.1, 5.2.2, 5.3.0, 5.4.0, 5.4.1, 5.5.0, 6.0.0rc1, 6.0.0, 6.1.0, 6.2.0, 6.2.1)
    
    No matching distribution found for ipython==8888
    
    

    选择一个5.X版本进行安装即可

    
    [root@www ~]# pip install ipython==5.5.0
    
    

    3)可能出现的错误

    安装过程中出现错误,提示“致命错误:Python.h:没有那个文件或目录”,由于缺失python-devel开发包所导致,python.h存在于python-devel开发包

    解决方法是安装python-devel,这是Python的头文件和静态库包

    
    [root@www ~]# yum install python-devel
    
    

    安装过程中需输入两次“y”,安装完成后再次执行IPython安装即可

    二、使用sublime text3编辑python脚本

    1、下载sublime text3的tar包

    wget  [https://download.sublimetext.com/sublime_text_3_build_3143_x64.tar.bz2](https://download.sublimetext.com/sublime_text_3_build_3143_x64.tar.bz2)
    

    2、解压安装包

    
    [root@www ~]# tar xvf sublime_text_3_build_3143_x64.tar.bz2
    
    

    3、进入解压好的sublime_text_3文件夹,启动sublime

    [root@www ~]# cd sublime_text_3/
    
    [root@www ~]# ./sublime_text
    

    使用SublimeText 作为Python 的开发环境

    https://jingyan.baidu.com/article/3065b3b684fdaebecff8a412.html

    sublimede 的具体使用方法可参考下面的文章

    如何优雅地使用Sublime Text

    https://jeffjade.com/2015/12/15/2015-04-17-toss-sublime-text/

    4、常用插件

    AdvancedNewFile

    Djaneiro

    Emmet

    Git

    Side Bar

    HTML/CSS/JS Prettify

    Python PEP8 Autoformat

    Sublimecodeintel

    ColorPicker

    OmniMarkupPreviewer

    pygments

    ConvertToUTF-8

    Terminal

    5、sublime text3 不能输入中文的解决方法

    1)下载我们需要的文件,打开终端 ,输入:

    [root@www ~]# git clone https://github.com/lyfeyaj/sublime-text-imfix.git
    

    2)将下载的文件解压之后,移到当前目录(~目录下边),然后执行下边命令:

    
    [root@www ~]# cd ~/sublime-text-imfix       (前提:解压后的sublime-text-imfix必须在~目录下)
    
    [root@www ~]# cp ./lib/libsublime-imfix.so /opt/sublime_text/
    
    [root@www ~]# cp ./src/subl /usr/bin/
    

    3)最后把sublime都关掉,然后在终端输入subl,就可以在sublime使用中文了(*必须在终端输入subl启动sublime才起作用的)

    注:这个方法sublime text 2也适用

    相关文章

      网友评论

          本文标题:Centos中的Python编程工具

          本文链接:https://www.haomeiwen.com/subject/olbegxtx.html