[英]How do I upgrade packages used by iPython?
I am using iPython on OSX (on system, not inside a virtualenv) and importing pandas into a notebook.我在 OSX 上使用 iPython(在系统上,而不是在 virtualenv 内)并将 pandas 导入笔记本。 My system python is Python 2.
我的系统 python 是 Python 2。
The version of pandas visible in the notebook is 0.16.2:笔记本中可见的 pandas 版本为 0.16.2:
import pandas as pd
print pd.__version__
I want to use pandas 0.18.我想使用 pandas 0.18。 So I have quit the notebook and run:
所以我退出了笔记本并运行:
pip install --upgrade ipython
pip install --upgrade pandas
This appeared to install ipython 4.1.2 and pandas 0.18.0, but if I run:这似乎安装了 ipython 4.1.2 和 pandas 0.18.0,但如果我运行:
ipython --version
I see v4.0.我看到了 v4.0。 And running my notebook still shows pandas 0.16.2.
运行我的笔记本仍然显示 pandas 0.16.2。
How do I upgrade my packages so that I can use pandas 0.18 inside my notebook?如何升级我的软件包,以便我可以在笔记本电脑中使用 pandas 0.18?
The ipython
command invokes the respective python script, which is typically stored at /usr/local/bin/ipython
. ipython
命令调用相应的 python 脚本,该脚本通常存储在/usr/local/bin/ipython
。 The first line of this script denotes the python version to be used.此脚本的第一行表示要使用的 Python 版本。 In my case it is
#!/usr/bin/python3.6
which means that ipython is using version 3.6 of python.就我而言,它是
#!/usr/bin/python3.6
,这意味着 ipython 使用的是 3.6 版的 python。 Use the command which ipython | xargs head -n 1
使用命令
which ipython | xargs head -n 1
which ipython | xargs head -n 1
to read this first line of your ipython script. which ipython | xargs head -n 1
读取 ipython 脚本的第一行。 Once you know which python version ipython is using you can invoke the upgrade command.一旦您知道 ipython 正在使用哪个 python 版本,您就可以调用升级命令。 In my case, I have to execute
pip3.6 install --upgrade ipython
and pip3.6 install --upgrade pandas
.就我而言,我必须执行
pip3.6 install --upgrade ipython
和pip3.6 install --upgrade pandas
。
pip
most likely points to python3
, you can sepecify what pip to use specifically: pip
最有可能指向python3
,您可以指定要具体使用的 pip :
pip2 install -U ipython
pip2 install -U pandas
Another reason can be having more than one version of python2 installed so pip may well point to another that interpreter, adding which -a pip
and which -a python
will show you what is installed.另一个原因可能是安装了多个版本的 python2,因此 pip 很可能指向另一个解释器,添加
which -a pip
和which -a python
将显示安装了什么。
如果您正在运行 iPython / Jupyter notebook,Padraic 的第二个想法可能是正确的,您可能正在运行 Anaconda 附带的 python,请尝试conda install pandas
使用以下命令可以更新 ipython,打开 cmd 并键入命令:
pip install ipython --upgrade
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.