推薦兩款在CentOS中進(jìn)行Python編程用的工具IPython和Sublime text剑辫,IPython適合新手初學(xué)時(shí)使用哭尝,Sublime text適合有經(jīng)驗(yàn)的人員使用驹吮。
一茸时、推薦使用ipython解釋器
1贡定、Centos下安裝pip
1)首先安裝epel擴(kuò)展源:
[root@www ~]# yum -y install epel-release
2)更新完成之后,就可安裝pip:
[root@www ~]# yum -y install python-pip
3)安裝完成之后清除cache:
[root@www ~]# yum clean all
4)對(duì)pip進(jìn)行升級(jí)
[root@www ~]# pip install --upgrade pip
2可都、安裝IPython
1)使用pip命令安裝IPython
[root@www ~]# pip install ipython
使用pip命令安裝IPython時(shí)經(jīng)常會(huì)出錯(cuò)缓待,當(dāng)Python版本等于或低于2.7.x時(shí)提示不能安裝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
先輸入一個(gè)不存在的版本號(hào),如: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
選擇一個(gè)5.X版本進(jìn)行安裝即可
[root@www ~]# pip install ipython==5.5.0
3)可能出現(xiàn)的錯(cuò)誤
安裝過(guò)程中出現(xiàn)錯(cuò)誤步悠,提示“致命錯(cuò)誤:Python.h:沒(méi)有那個(gè)文件或目錄”,由于缺失python-devel開發(fā)包所導(dǎo)致瘫镇,python.h存在于python-devel開發(fā)包
解決方法是安裝python-devel鼎兽,這是Python的頭文件和靜態(tài)庫(kù)包
[root@www ~]# yum install python-devel
安裝過(guò)程中需輸入兩次“y”,安裝完成后再次執(zhí)行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尚粘、進(jìn)入解壓好的sublime_text_3文件夾择卦,啟動(dòng)sublime
[root@www ~]# cd sublime_text_3/
[root@www ~]# ./sublime_text
使用SublimeText 作為Python 的開發(fā)環(huán)境
https://jingyan.baidu.com/article/3065b3b684fdaebecff8a412.html
sublimede 的具體使用方法可參考下面的文章
如何優(yōu)雅地使用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)將下載的文件解壓之后秉继,移到當(dāng)前目錄(~目錄下邊),然后執(zhí)行下邊命令:
[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都關(guān)掉泽铛,然后在終端輸入subl秕噪,就可以在sublime使用中文了(*必須在終端輸入subl啟動(dòng)sublime才起作用的)
注:這個(gè)方法sublime text 2也適用