在 ubuntu linux 上安装 jq 的 Python 绑定时遇到问题

问题描述 投票:0回答:2

我一直在尝试使用 pip 在 ubuntu 上安装 jq 的 Python 绑定。

但是,当我运行以下命令时,它失败了。

sudo pip install jq

这是它收到的错误消息。

Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EmO25q/jq/setup.py';exec(compile(getattr(tokenize, 'open', open)
(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-RBT2h7-record/install-record.txt --single-version-externally-m
anaged --compile" failed with error code 1 in /tmp/pip-build-EmO25q/jq/
python linux ubuntu jq
2个回答
4
投票

这将被编译,您需要安装构建依赖项。

apt-get install autoconf automake build-essential libtool python-dev

请参阅 Pypi 页面了解更多信息... https://pypi.python.org/pypi/jq/0.1.6


0
投票

也遇到了这个问题。因此,为那些不想编译任何东西并安装不相关的构建工具链的人推出了另一场狂欢。

替代 JQ Python 绑定称为 JQpy

安装:

sudo apt-get update && sudo apt-get install jq
pip install jqpy

示例:

>>> from jqpy import jq
>>> jq('.results[] | {age, city}', {
                "timestamp": 1234567890,
                "report": "Age Report",
                "results": [
                        { "name": "John", "age": 43, "city": "TownA" },
                        { "name": "Joe",  "age": 10, "city": "TownB" }
                ]
        })
[{'age': 43, 'city': 'TownA'}, {'age': 10, 'city': 'TownB'}]
© www.soinside.com 2019 - 2024. All rights reserved.