IPython是python的一个第三方库,本来使用pip(类似于linux的yum)工具是很容易安装的,但是因为版本原因有时会出些问题,比如2.7.x版本的不能安装IPython的最新版本,会报错:


报错如下:


[root@iZ2ze7qh7q0di3qkvef1dzZ~]#pipinstallipythonLookinginindexes:http://mirrors.aliyun.com/pypi/simple/CollectingipythonDownloadinghttp://mirrors.aliyun.com/pypi/packages/f3/c3/6c0af5b99d9551fa7b33c674d8f1232033678dcc817098e7a4ac8cd0baf1/ipython-7.1.1.tar.gz(5.1MB)100%|████████████████████████████████|5.1MB97.5MB/sCompleteoutputfromcommandpythonsetup.pyegg_info:IPython7.0+supportsPython3.5andabove.WhenusingPython2.7,pleaseinstallIPython5.xLTSLongTermSupportversion.Python3.3and3.4weresupporteduptoIPython6.x.SeeIPython`README.rst`fileformoreinformation:https://github.com/ipython/ipython/blob/master/README.rstPythonsys.version_info(major=2,minor=7,micro=5,releaselevel='final',serial=0)detected.----------------------------------------Command"pythonsetup.pyegg_info"failedwitherrorcode1in/tmp/pip-install-MKVcGm/ipython/


这时候就需要一种方法来测试下当前都有什么版本,用如下命令pip install ipython==0000,0000是胡乱写的,这样就会提示所有的版本,我们找一个中间的,别太新就行,本例是用5.3.0

(helloworld)[root@iZ2ze7qh7q0di3qkvef1dzZbin]#pipinstallipython==0000Lookinginindexes:http://mirrors.aliyun.com/pypi/simple/Collectingipython==0000Couldnotfindaversionthatsatisfiestherequirementipython==0000(fromversions: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,5.6.0,5.7.0,5.8.0,6.0.0rc1,6.0.0,6.1.0,6.2.0,6.2.1,6.3.0,6.3.1,6.4.0,6.5.0,7.0.0b1,7.0.0rc1,7.0.0,7.0.1,7.1.0,7.1.1)Nomatchingdistributionfoundforipython==0000(helloworld)[root@iZ2ze7qh7q0di3qkvef1dzZbin]#(helloworld)[root@iZ2ze7qh7q0di3qkvef1dzZbin]#(helloworld)[root@iZ2ze7qh7q0di3qkvef1dzZbin]#pipinstallipython==5.3.0


安装之后查下都安装了那些组件用pip list


(helloworld)[root@iZ2ze7qh7q0di3qkvef1dzZbin]#piplistPackageVersion-----------------------------------------backports.shutil-get-terminal-size1.0.0decorator4.3.0enum341.1.6ipython5.3.0ipython-genutils0.2.0pathlib22.3.2pexpect4.6.0pickleshare0.7.5pip18.1prompt-toolkit1.0.15ptyprocess0.6.0Pygments2.2.0redis2.10.6scandir1.9.0setuptools40.5.0simplegeneric0.8.1six1.11.0traitlets4.3.2wcwidth0.1.7wheel0.32.2


现在ipython就可以用了

(helloworld)[root@iZ2ze7qh7q0di3qkvef1dzZbin]#ipythonPython2.7.5(default,Aug42017,00:39:18)Type"copyright","credits"or"license"formoreinformation.IPython5.3.0--AnenhancedInteractivePython.?->IntroductionandoverviewofIPython'sfeatures.%quickref->Quickreference.help->Python'sownhelpsystem.object?->Detailsabout'object',use'object??'forextradetails.In[1]:print"helloworld"helloworld