【问题标题】:Pandas is not getting installed in UbuntuPandas 未安装在 Ubuntu 中
【发布时间】:2019-08-27 09:00:10
【问题描述】:

我正在尝试在我的 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

【问题讨论】:

  • 什么是python -Vpip --version
  • 对我来说似乎是为 Python 2 安装的 - pandas&gt;=0.25 放弃了对 Python 2.7 和 3.5 之前的所有 Python 3 版本的支持,因此请使用 pip install "pandas&lt;0.25"
  • 我认为使用pipenvvirtualvenv可以避免这个问题。

标签: python pandas pip


【解决方案1】:

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

这一行还有另一个提示,

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

这是给予

SyntaxError: invalid syntax

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


Pandas 库已放弃对 python 版本 的支持。从他们的官方doc 查看支持的版本。它指出,

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

根据他们的 PyPI page

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

您可以使用以下命令安装它。

pip install pandas==0.24.2

Python 2.7 将于 2020 年 1 月 1 日结束生命周期。请升级您的 Python,因为 Python 2.7 在该日期之后将不再维护。

【讨论】:

  • 请注意:pandas 安装需要 numpy,并且您还需要与 python 2.x 兼容的版本。我相信pip install numpy==1.16.3 为您提供了与 Python 2.x 兼容的最新版本。
猜你喜欢
  • 2016-10-19
  • 1970-01-01
  • 2020-04-30
  • 1970-01-01
  • 2013-06-16
  • 2021-03-24
  • 1970-01-01
  • 2016-03-04
  • 1970-01-01
相关资源
最近更新 更多