未在Ubuntu中安装Pandas

Sac*_*dav 7 python pip pandas

我试图在我的ubuntu机器上安装pandas库,但没有安装。

pip install pandas
pip3 install pandas
Run Code Online (Sandbox Code Playgroud)

我用过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
Run Code Online (Sandbox Code Playgroud)

Cod*_*eIt 6

从错误日志中可以清楚地看到OP正在使用不受支持的python版本。这就是PIP尝试使用pandas-0.25.1.tar.gz文件安装熊猫的原因。

这条线还有另一个提示,

print("Adding sample versioneer config to setup.cfg", file=sys.stderr)
                                                          ^
Run Code Online (Sandbox Code Playgroud)

这给

SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

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


Pandas库已放弃对python版本3.5.3以下的支持。请从其官方文档中查看受支持的版本。它指出,

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

根据他们的PyPI 页面

它支持Python版本的最新版本<3.5.30.24.2

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

pip install pandas==0.24.2
Run Code Online (Sandbox Code Playgroud)

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

  • 请注意:pandas安装需要numpy,并且您还将需要与python 2.x兼容的版本。我相信`pip install numpy == 1.16.3`为您提供了与Python 2.x兼容的最新版本。 (3认同)