如何为 Python 2 安装 pandas 而不是在我的默认 Python 3.6 上安装?

如何为 Python 2 安装 pandas 而不是在我的默认 Python 3.6 上安装?

我想在我的 ubuntu 18.04 上安装适用于 python2 的 pandas。

当我尝试使用安装熊猫时

pip install pandas 

我得到:

Requirement already satisfied: pandas in /home/apoorv/anaconda3/lib/python3.6/site-packages (0.24.1)
Requirement already satisfied: python-dateutil>=2.5.0 in /home/apoorv/anaconda3/lib/python3.6/site-packages (from pandas) (2.6.0)
Requirement already satisfied: numpy>=1.12.0 in /home/apoorv/anaconda3/lib/python3.6/site-packages (from pandas) (1.15.1)
Requirement already satisfied: pytz>=2011k in /home/apoorv/.local/lib/python3.6/site-packages (from pandas) (2018.5)
Requirement already satisfied: six>=1.5 in /home/apoorv/anaconda3/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)

我收到的错误:

apoorv@apoorv:~/Desktop$ python2
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>> 

如何安装?

答案1

包含 pandas 库的 python 2 包名为python-pandas

sudo apt install python-pandas

相关内容