python之Ipython的安装使用以及指定python版本号
程序员文章站
2022-05-27 23:15:20
...
为什么要使用ipython,因为方便,可以在里面使用一些linux中的命令,比如ls,cd等命令。
1、安装:
[[email protected] cs]# yum list | grep ipython # 先查看yum源中是否有这个包,如果有就可以安装,如果没有的话那就不行了,需要从官网下载然后自行进行安装
python-ipython.noarch 3.2.1-1.el7 @epel
python-ipython-console.noarch 3.2.1-1.el7 @epel
python-ipython-gui.noarch 3.2.1-1.el7 @epel
python-ipython-doc.noarch 3.2.1-1.el7 epel
python-ipython-sphinx.noarch 3.2.1-1.el7 epel
python-ipython-tests.noarch 3.2.1-1.el7 epel
python2-ipython_genutils.noarch 0.1.0-7.el7 epel
python34-ipython_genutils.noarch 0.1.0-7.el7 epel
[[email protected] cs]# yum install ipython.noarch # 安装这个包
验证安装是否成功:
[[email protected] cs]# ipython
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
Type "copyright", "credits" or "license" for more information.
IPython 3.2.1 -- 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]: ls
In [2]:
2、使用:
可以看到下面我们可以使用Linux中的命令,也可以使用python中的命令;这就非常方便了!
[[email protected] cs]# ipython
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
Type "copyright", "credits" or "license" for more information.
IPython 3.2.1 -- 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]: cd /
/
In [2]: ls
[email protected] boot/ dev/ etc/ home/ [email protected] [email protected] lost+found/ media/ mnt/ opt/ proc/ root/ run/ [email protected] srv/ sys/ tmp/ usr/ var/
In [3]: pwd
Out[3]: u'/'
In [4]: import os
In [5]: os.getcwd()
Out[5]: '/'
In [6]: exit
[[email protected] cs]#
3、修改ipython中的python版本号:
我们可能系统中有不同的python版本,故而使用ipython的时候就会有不同的版本要求了,默认ipython安装会采用系统默认的版本,这个时候可能就不满足我们的需要了,所以需要手动更改一下ipython的版本号;
查看现在ipython的版本号:
方法一:在你进入ipython的时候会显示python的版本号了;
[[email protected] cs]# ipython
Python 2.7.5 (default, Jul 13 2018, 13:06:57)
Type "copyright", "credits" or "license" for more information.
IPython 3.2.1 -- 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
[[email protected] cs]#
方法二:进入ipython中输入htlp()就可以在第一行看到相关信息了;
In [2]: help()
Welcome to Python 2.7! This is the online help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".
help>
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
In [3]:
修改ipython的版本号:
查看配置文件:
[[email protected] cs]# which ipython
/usr/bin/ipython
[[email protected] cs]# cat /usr/bin/ipython
#!/usr/bin/python2 # 第一行就是指定的python编译器,我们改成自己想要使用的python版本就行了
# This script was automatically generated by setup.py
if __name__ == '__main__':
from IPython import start_ipython
start_ipython()
修改配置文件:具体的python编译器的路径需要看你实际的地址是多少
[[email protected] cs]# cat /usr/bin/ipython
#!/root/.pyenv/versions/3.5.0/bin/python # 只有第一行指定的有效,所以我们插入这条信息就行了
#!/usr/bin/python2
# This script was automatically generated by setup.py
if __name__ == '__main__':
from IPython import start_ipython
start_ipython()
使用:我报错如下,说是没有“Ipython”模块,需要我们手动下载一下;
[[email protected] cs]# ipython
Traceback (most recent call last):
File "/usr/bin/ipython", line 5, in <module>
from IPython import start_ipython
ImportError: No module named 'IPython'
[[email protected] cs]#
安装Ipython模块;
[[email protected] cs]# pip install Ipython
。。。。。。。
。。。。。。。
Running setup.py install for simplegeneric ... done
Running setup.py install for backcall ... done
Found existing installation: setuptools 18.2
Uninstalling setuptools-18.2:
Successfully uninstalled setuptools-18.2
[[email protected] cs]#
重新使用ipython:这个时候我们就可以看到ipython已经成功的变成了我们需要的python版本了,嘻嘻嘻!
[[email protected] cs]# ipython
Python 3.5.0 (default, Aug 8 2018, 09:59:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: exit
[[email protected] cs]#
至此,就完成了!吃饭去!
上一篇: Ubuntu 18 安装DNS解析服务器
下一篇: ubuntu 16.04 grpc搭建
推荐阅读
-
python——虚拟环境之pipenv的安装及使用(windows10,64位)
-
Linux学习笔记之Python3的安装以及创建虚拟环境(CentOS)
-
python爬虫之selenium库的安装及使用教程
-
python之OpenCV的作用以及安装案例教程
-
python编写脚本之pyautogui的安装和使用教程
-
python的pip安装以及使用教程
-
Mac下载Python2和Python3的安装配置以及相互切换使用
-
Python 工具 之 Scrapy 环境搭建(Twisted插件下载安装),以及 Scrapy 框架的简单使用说明
-
window环境python如何安装模块,以及ipython的使用
-
python之Ipython的安装使用以及指定python版本号