pandas 如何升级 iPython 使用的软件包?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36218233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I upgrade packages used by iPython?
提问by Richard
I am using iPython on OSX (on system, not inside a virtualenv) and importing pandas into a notebook. My system python is Python 2.
我在 OSX 上使用 iPython(在系统上,而不是在 virtualenv 中)并将Pandas导入到笔记本中。我的系统 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. So I have quit the notebook and run:
我想使用Pandas 0.18。所以我退出了笔记本并运行:
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. And running my notebook still shows pandas 0.16.2.
我看到了 v4.0。运行我的笔记本仍然显示 pandas 0.16.2。
How do I upgrade my packages so that I can use pandas 0.18 inside my notebook?
如何升级我的软件包以便我可以在我的笔记本中使用 pandas 0.18?
回答by jboockmann
The ipython
command invokes the respective python script, which is typically stored at /usr/local/bin/ipython
. The first line of this script denotes the python version to be used. In my case it is #!/usr/bin/python3.6
which means that ipython is using version 3.6 of python. Use the command which ipython | xargs head -n 1
to read this first line of your ipython script.
Once you know which python version ipython is using you can invoke the upgrade command. In my case, I have to execute pip3.6 install --upgrade ipython
and pip3.6 install --upgrade pandas
.
该ipython
命令调用相应的 python 脚本,该脚本通常存储在/usr/local/bin/ipython
. 此脚本的第一行表示要使用的 Python 版本。就我而言,#!/usr/bin/python3.6
这意味着 ipython 使用的是 3.6 版的 python。使用该命令which ipython | xargs head -n 1
读取 ipython 脚本的第一行。一旦您知道 ipython 正在使用哪个 python 版本,您就可以调用升级命令。就我而言,我必须执行 pip3.6 install --upgrade ipython
和pip3.6 install --upgrade pandas
。
回答by farshad
Using the following command you can update ipython, Open cmd and type the command:
使用以下命令可以更新 ipython,打开 cmd 并键入命令:
pip install ipython --upgrade
回答by Padraic Cunningham
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
显示安装的内容。
回答by mattvivier
If you're running the iPython / Jupyter notebook, Padraic's second thought is probably correct, you're probably running the python that came with Anaconda, try conda install pandas
如果您正在运行 iPython / Jupyter notebook,Padraic 的第二个想法可能是正确的,您可能正在运行 Anaconda 附带的 python,请尝试 conda install pandas