python - Pandas 未安装在 Ubuntu 中
问题描述
我正在尝试在我的 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
解决方案
从错误日志中可以清楚地看出,OP 正在使用不受支持的 python 版本。这就是为什么 PIP 尝试使用 file.pandas 安装 pandas 的原因pandas-0.25.1.tar.gz
。
另一个提示是在这一行,
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 版本< 3.5.3的支持。从他们的官方文档中查看支持的版本。它指出,
正式 Python 3.5.3 及更高版本、3.6 和 3.7。
根据他们的 PyPI页面,
支持 python 版本< 3.5.3的最新版本是0.24.2。
您可以使用以下命令安装它。
pip install pandas==0.24.2
Python 2.7将于2020 年 1 月 1 日结束生命周期。请升级您的 Python,因为 Python 2.7 在该日期之后将不再维护。
推荐阅读
- android - 如何从代码(Java/Kotlin)文件中更改可绘制背景颜色
- powershell - 用于替换名称的 Powershell 脚本
- singularity-container - 具有相对路径的奇点定义文件
- swift - 无法使用 coreML 对手绘图像进行分类
- python - 目录和 python 字典
- python - 如何从 tkinter 获取条目的值
- nginx - 如果不是来自特定 IP,Nginx 如何阻止空用户代理
- javascript - 在jquery中查找前一个元素
- javascript - SCRIPT1003:IE 11 + angular 7 + vendor.js 中的预期':'
- flutter - 如何在发短信时使用向上和向下箭头从文本字段中选择建议