有没有一种方法可以在Ubuntu 10.04上安装jq JSON处理器?
我尝试了通常的sudo apt-get install jq
但是出现了错误E:无法找到软件包jq
有没有一种方法可以在Ubuntu 10.04上安装jq JSON处理器?
我尝试了通常的sudo apt-get install jq
但是出现了错误E:无法找到软件包jq
可以执行sudo apt-get install jq
,但需要告诉系统在哪里找到jq。
ℹ️ 注意:Ubuntu 14+用户可以跳过第3步!
使用文本编辑器打开您的源文件:
sudo vim /etc/apt/sources.list
在文件末尾添加以下行(注意deb
不是一个命令,更多信息):
deb http://us.archive.ubuntu.com/ubuntu vivid main universe
然后重新索引apt-get,以便它可以找到jq
:
sudo apt-get update
然后进行正常安装,你将会成为自豪的新用户jq
! sudo apt-get install jq
测试它是否可用!尝试这个示例以查看它漂亮地打印一些示例 JSON
echo '{ "name":"John", "age":31, "city":"New York" }' | jq .
在您的终端中,结果应该看起来像这样:
{
"name": "John",
"age": 31,
"city": "New York"
}
sudo apt-get update
命令会出现一些错误,例如“无法下载某些索引文件。它们已被忽略或者使用旧的文件代替。”执行sudo apt-get install jq
仍然失败。如何修复这个问题(Ubuntu 17.04)?自动更新也失败了,告诉我检查我的网络连接,但其他网络访问正常(Git、Firefox等)。顺便说一下,这是在虚拟机中运行的。 - CodeManXapt-get install jq
,而不需要修改sources.list
。 - ᴍᴇʜᴏᴠsudo apt-get update
之前,我一直遇到E: Couldn't find package jq
错误。因此,对于版本14及以上的系统,最好从第3步开始操作。 - artifex按照https://stedolan.github.io/jq/download/中所述的方式从源代码下载并构建,具体请参考最后一个章节 "在Linux、OS X、Cygwin和其他类POSIX操作系统上从源代码构建"。
如果您没有sudo权限,请执行以下操作:
#!/usr/bin/env bash
# conda activate jq_install_env
# - Install jq without sudo
# Clone the jq repository from GitHub
cd $HOME
git clone https://github.com/stedolan/jq.git $HOME/jq
cd $HOME/jq
git submodule update --init
# Compile jq from source
cd $HOME/jq
autoreconf -fi
./configure --with-oniguruma=builtin --disable-maintainer-mode --prefix=$HOME/.local
make -j8 && make check
make install
ls $HOME/.local
ls $HOME/.local/bin
# Add the directory where the jq binary file is located to your PATH environment variable
echo 'PATH=$PATH:~/.local/bin/' >> $HOME/.bashrc.lfs
export PATH=$PATH:~/.local/bin/
echo $PATH | tr ':' '\n'
# Reload your shell configuration file to update your PATH environment variable
source $HOME/.bashrc.lfs
# Verify that jq is installed and working
jq --version
参考链接:https://suzyahyah.github.io/misc/2020/03/31/jq-without-sudo.html
如果链接失效:
Landing Page...
AboutCategoriesAdvisors
Recipe for building jq from source without admin(sudo) rights
Mar 31, 2020
This took me some time to install. Just putting it out there in case it helps someone.
Get the latest jq from github
git clone https://github.com/stedolan/jq.git
Update submodules (onigurama)
git submodule update --init
Copy missing auxiliary files
autoreconf -fi
Install into {YOUR_HOME_DIR} with onigurama (regex library)
./configure --with-oniguruma=builtin --disable-maintainer-mode --prefix={YOUR_HOME_DIR}.local
Check that we have all the dependencies downloaded and install
make -j8 && make check
make install
Finally, add this to your ~/.bashrc and to call jq from anywhere. Remember to >source ~/.bashrc and you should be good to go.
export PATH=$PATH:~/.local/bin/
« The Sigmoid in Regression, Neural Network Activation and LSTM GatesA minimum keystroke (py)Debugger for Lazy ML/DS people who don't IDE »
Quality means doing it right when no one is looking - Henry Ford
suzyahyah
suzyahyah
The best time to plant a tree was 20 years ago. The second best time is now. - Japanese proverb
Since October 2017