我ipython
使用进行安装python-pip
。以下是回溯:
user@MY-PC:~$ sudo pip install ipython
[sudo] password for user:
Downloading/unpacking ipython
Downloading ipython-2.3.0-py27-none-any.whl (2.8MB): 2.8MB downloaded
Installing collected packages: ipython
Successfully installed ipython
Cleaning up...
但是,当我运行dpkg -s
和dpkg -l
命令来检查版本时,终端给出了以下输出:
user@MY-PC:~$ dpkg -s ipython | grep Version
dpkg-query: package 'ipython' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
user@MY-PC:~$ dpkg -l ipython
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un ipython <none> <none> (no description available)
这里出了什么问题?我该如何验证我的安装ipython
并检查其版本?
答案1
尝试一下sudo apt-get install ipython
。我认为 pip 命令是用于 python 本身(安装模块等)而不是用于安装系统程序,只是猜测,不确定。
也许尝试
python ipython
或者python
然后import ipython
或者ipython
答案2
您已将其安装为源包,目标是将其用作代码上的库。
为了检查它,请python
在终端中输入以打开 shell 并尝试导入它:
import ipython
如果没有错误,则表示一切正常。例如:
>>> import os # This package exist and it's installed!
>>> os
<module 'os' from '/usr/lib/python2.7/os.pyc'>
>>> import bottle # This package exist but it's not installed!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bottle
>>> bottle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'bottle' is not defined
恰巧你指定的包提供了基于终端的交互式 Python shell(读文档),这样您就可以在终端中ipython
像运行任何其他命令一样使用它。
这是一个非常特殊的情况,并不适用于每个 Python 包。