未在Ubuntu中安装Pandas

时间:2019-08-27 09:00:10

标签: python pandas pip

我正在尝试在ubuntu机器上安装pandas库,但尚未安装。

pip install pandas
pip3 install pandas

我用过pip install pandas

Downloading/unpacking pandas
  Downloading pandas-0.25.1.tar.gz (12.6MB): 12.6MB downloaded
  Running setup.py (path:/tmp/pip-build-WzvvgM/pandas/setup.py) egg_info for package pandas
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-WzvvgM/pandas/setup.py", line 21, in <module>
        import versioneer
      File "versioneer.py", line 1629
        print("Adding sample versioneer config to setup.cfg", file=sys.stderr)
                                                                  ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip-build-WzvvgM/pandas/setup.py", line 21, in <module>

    import versioneer

  File "versioneer.py", line 1629

    print("Adding sample versioneer config to setup.cfg", file=sys.stderr)

                                                              ^

SyntaxError: invalid syntax

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-WzvvgM/pandas
Storing debug log for failure in /home/user508/.pip/pip.log

1 个答案:

答案 0 :(得分:6)

从错误日志中很明显,OP正在使用不受支持的python版本。这就是PIP尝试使用pandas-0.25.1.tar.gz文件安装熊猫的原因。

此行中还有另一个提示

print("Adding sample versioneer config to setup.cfg", file=sys.stderr)
                                                          ^

正在提供

SyntaxError: invalid syntax

此错误清楚地表明OP正在使用 Python 2.x 。上面的打印语句是Python 3.x的语句,在 Python 2.x 中使用时返回错误。例如,请参见此repl


Pandas库已不再支持python版本 <3.5.3 。请从官方doc查看受支持的版本。它指出,

  

正式是Python 3.5.3及更高版本,3.6和3.7。

根据他们的PyPI page

支持python版本 <3.5.3 的最新版本是 0.24.2

您可以使用以下命令进行安装。

pip install pandas==0.24.2
  

Python 2.7 将于 2020年1月1日 到期。请升级,在该日期之后将不再维护您的Python,即Python 2.7。