ITPub博客

首页 > 应用开发 > > 使用不同版本的python来启动ipython

使用不同版本的python来启动ipython

作者:daqianmen 时间:2019-09-10 16:05:53 0 删除 编辑

我的笔记本上有多个python3的版本, 3.5, 3.6, 3.7 都有,我有时候想要在不同的python版本间切换。后来得知有两种办法,第一种方法.

1. python[VERION] -m IPython

python3.6 -m IPython
Python 3.6.6 (default, Jun 27 2018, 14:44:17) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.0 -- 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]: exit
root@kali:/usr/local/src/py/test_examples# python3.7 -m IPython
Python 3.7.2+ (default, Feb 2 2019, 14:31:48) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.0 -- 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.
2.  ipython 其实是个shell 脚本。我有多个ipython版本,打开看看内容,就是个简单的bash脚本,把VERSION这个变量修改下,就能Invoke不同的python版本
/usr/bin/ipython3
/usr/bin/ipython
#! /bin/sh

VERSION="3.7"

if [ ! -f /usr/bin/python$VERSION ]
then
    echo "Please install the python$VERSION package." >&2
    exit 1
else
    exec python$VERSION -c "import sys; sys.argv[0] = '/usr/bin/ipython$VERSION'; from IPython.terminal.ipapp import launch_new_instance; launch_new_instance()" "$@"
fi


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1727/viewspace-3133859/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-07-31

  • 博文量
    108
  • 访问量
    34266