简体   繁体   中英

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. My system python is Python 2.

The version of pandas visible in the notebook is 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:

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 --version

I see v4.0. And running my notebook still shows pandas 0.16.2.

How do I upgrade my packages so that I can use pandas 0.18 inside my notebook?

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 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 .

pip most likely points to python3 , you can sepecify what pip to use specifically:

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.

如果您正在运行 iPython / Jupyter notebook,Padraic 的第二个想法可能是正确的,您可能正在运行 Anaconda 附带的 python,请尝试conda install pandas

使用以下命令可以更新 ipython,打开 cmd 并键入命令:

pip install ipython --upgrade

ipython3

To change ipython from version 3.8 to 3.10, I edited first line of /usr/bin/ipython3 to #./usr/bin/python3.10

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM