34

While installing jq on centos, I am experiencing an issue. I have run the following commands:

yum groupinstall "Development Tools"
yum install autoconf automake libtool python

after that I have used pip install jq and I was facing error like this:

jq.c:8:22: fatal error: pyconfig.h: No such file or directory
#include "pyconfig.h"
                     ^
compilation terminated.
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-akuaZu/jq/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read                                                                                        ().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" 
instal --record /tmp/pip-04CW9h-record/install-record.txt --single-version-externally  
-managed --compile" failed with error code 1 in /tmp/pip-build-akuaZu/jq/

Can anyone help me??

3 Answers 3

131

Just in case if someone is looking for a different solution.

This is how I installed in Cent OS 7 and it worked. Ensure you have sudo privilege.

Installer solution

yum install epel-release -y
yum install jq -y
jq --version

output was jq-1.5

Reference

4
  • 3
    +1 and also you can't do yum install epel-release jq -y. the epel repository has to be installed first
    – mles
    Commented Dec 19, 2017 at 13:09
  • This should be the number one answer. Easy manageable with the yum package manager for updates Commented Feb 6, 2019 at 3:08
  • Fwiw, with yum I got version 1.3 because older CentOS, but wanted some of the newer functions, so I downloaded the binary jq-1.6 and it seems to work fine under CentOS 6, also. (I am not good at yum and related things..)
    – MSpreij
    Commented Feb 14, 2019 at 16:00
  • Using this method, I get a very long failure message when I run yum install jq. It ends with: Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
    – Br.Bill
    Commented Jul 25, 2019 at 18:39
24

This is how I installed it on CentOS 7:

wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -O jq
chmod +x jq

Then

mv jq /usr/local/bin
3
  • 1
    Please use yum whenever possible.
    – CodeMed
    Commented Apr 5, 2018 at 18:49
  • @CodeMed yum wasn't happening for either the OP or me at the time.
    – hmedia1
    Commented Apr 6, 2018 at 7:37
  • 3
    jq still isn't available via yum as of today.
    – thepip3r
    Commented Aug 10, 2020 at 19:43
10

Install pre-req & install jq

$ sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

$ sudo yum install jq -y

more usage info.. https://medium.com/@gchandra/install-jq-on-centos-7-459dd650baa3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.