Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1754848
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: Python/Ruby

2019-03-24 16:03:13

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

1. python[VERION] -m IPython

点击(此处)折叠或打开

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

  4. IPython 5.5.0 -- An enhanced Interactive Python.
  5. ? -> Introduction and overview of IPython's features.
  6. %quickref -> Quick reference.
  7. help -> Python's own help system.
  8. object? -> Details about 'object', use 'object??' for extra details.

  9. In [1]: exit
  10. root@kali:/usr/local/src/py/test_examples# python3.7 -m IPython
  11. Python 3.7.2+ (default, Feb 2 2019, 14:31:48)
  12. Type "copyright", "credits" or "license" for more information.

  13. IPython 5.5.0 -- An enhanced Interactive Python.
  14. ? -> Introduction and overview of IPython's features.
  15. %quickref -> Quick reference.
  16. help -> Python's own help system.
  17. object? -> Details about 'object', use 'object??' for extra details.
2.  ipython 其实是个shell 脚本。我有多个ipython版本,打开看看内容,就是个简单的bash脚本,把VERSION这个变量修改下,就能Invoke不同的python版本.

点击(此处)折叠或打开


  1. /usr/bin/ipython3
  2. /usr/bin/ipython

点击(此处)折叠或打开

  1. #! /bin/sh

  2. VERSION="3.7"

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



阅读(112156) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~