导读记录在CentOS7.5下Python 3安装IPython的过程,希望对大家有所帮助。

一、通过压缩包安装ipython1、下载IPython安装包

$wgethttps://files.pythonhosted.org/packages/82/0a/146b0f0f1ddf13ab8682aed5c5a42250cddf1082e193ec95b50b03b9f791/ipython-7.3.0.tar.gz2、安装IPython

[root@localhost~]#tarxfipython-7.3.0.tar.gz[root@localhost~]#cdipython-7.3.0[root@localhostipython-7.3.0]#pwd/root/ipython-7.3.0[root@localhostipython-7.3.0]#python3setup.pyinstall

#前提已安装python3,
#Linux系统安装Python3 见 : http://www.cnblogs.com/chengd/p/7078498.html

3、通过pip安装ipython所有缺失模块,直至ipython运行成功

[root@localhostipython]#ipythonTraceback(mostrecentcalllast):File"/usr/local/bin/ipython",line4,in<module>fromIPythonimportstart_ipythonFile"/usr/local/lib/python3.7/site-packages/IPython/__init__.py",line54,in<module>from.core.applicationimportApplicationFile"/usr/local/lib/python3.7/site-packages/IPython/core/application.py",line23,in<module>fromtraitlets.config.applicationimportApplication,catch_config_errorModuleNotFoundError:Nomodulenamed'traitlets'

#运行ipython是提示缺少'traitlets'模块;
#安装提示一步步通过pip安装缺失模块

[root@localhostipython]#pipinstall'traitlets'CollectingtraitletsDownloadinghttps://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl(74kB)100%|████████████████████████████████|81kB100kB/sRequirementalreadysatisfied(use--upgradetoupgrade):enum34;python_version=="2.7"in/usr/lib/python2.7/site-packages(fromtraitlets)Requirementalreadysatisfied(use--upgradetoupgrade):sixin/usr/lib/python2.7/site-packages(fromtraitlets)Collectingipython-genutils(fromtraitlets)Downloadinghttps://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whlRequirementalreadysatisfied(use--upgradetoupgrade):decoratorin/usr/lib/python2.7/site-packages(fromtraitlets)Installingcollectedpackages:ipython-genutils,traitletsSuccessfullyinstalledipython-genutils-0.2.0traitlets-4.3.2Youareusingpipversion8.1.2,howeverversion19.0.3isavailable.Youshouldconsiderupgradingviathe'pipinstall--upgradepip'command.

升级pip

[root@localhostipython]#pipinstall--upgradepipCollectingpipDownloadinghttps://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl(1.4MB)68%|█████████████████████▉|921kB8.5kB/seta0:00:51100%|████████████████████████████████|1.4MB73kB/sInstallingcollectedpackages:pipFoundexistinginstallation:pip8.1.2Uninstallingpip-8.1.2:Successfullyuninstalledpip-8.1.2Successfullyinstalledpip-19.0.3

二、直接通过pip安装ipython

pip安装地址:https://www.linuxidc.com/Linux/2019-02/157062.htm

[root@localhostpip-9.0.1]#pipinstallipython[root@localhostpip-9.0.1]#ipythonipythonipython3[root@localhostpip-9.0.1]#ipython3/usr/local/lib/python3.6/site-packages/IPython/core/history.py:226:UserWarning:IPythonHistoryrequiresSQLite,yourhistorywillnotbesavedwarn("IPythonHistoryrequiresSQLite,yourhistorywillnotbesaved")Python3.6.1(default,Jun262017,09:16:04)Type'copyright','credits'or'license'formoreinformationIPython6.1.0--AnenhancedInteractivePython.Type'?'forhelp.In[1]:#ipython安装成功

原文来自:https://www.linuxprobe.com/python-ipython-share.html