加载共享库时出错:libreadline.so.7:无法打开共享对象文件:没有此文件或目录

加载共享库时出错:libreadline.so.7:无法打开共享对象文件:没有此文件或目录

我正在尝试设置环境deepmind/dqn.我运行./install_dependencies.sh安装

LuaJIT and Torch 7.0
nngraph
Xitari
AleWrap

但我得到了:

/home/dqn/torch/bin/luajit: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory

=> Torch7 has been installed successfully

Installing nngraph ...
/home/dqn/torch/bin/luajit: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory
Error. Exiting.

install_dependencies.sh

# Install dependencies for Torch:
sudo apt-get update
sudo apt-get install -qqy build-essential
sudo apt-get install -qqy gcc g++
sudo apt-get install -qqy cmake
sudo apt-get install -qqy curl
sudo apt-get install -qqy libreadline-dev
sudo apt-get install -qqy git-core
sudo apt-get install -qqy libjpeg-dev
sudo apt-get install -qqy libpng-dev
sudo apt-get install -qqy ncurses-dev
sudo apt-get install -qqy imagemagick
sudo apt-get install -qqy unzip
sudo apt-get update

echo "==> Torch7's dependencies have been installed"

# Build and install Torch7
cd /tmp
rm -rf luajit-rocks
git clone https://github.com/torch/luajit-rocks.git
cd luajit-rocks
mkdir -p build
cd build
git checkout master; git pull
rm -f CMakeCache.txt
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make install
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi


path_to_nvcc=$(which nvcc)
if [ -x "$path_to_nvcc" ]
then
cutorch=ok
cunn=ok
fi

# Install base packages:
$PREFIX/bin/luarocks install cwrap
$PREFIX/bin/luarocks install paths
$PREFIX/bin/luarocks install torch
$PREFIX/bin/luarocks install nn

[ -n "$cutorch" ] && \
($PREFIX/bin/luarocks install cutorch)
[ -n "$cunn" ] && \
($PREFIX/bin/luarocks install cunn)

$PREFIX/bin/luarocks install luafilesystem
$PREFIX/bin/luarocks install penlight
$PREFIX/bin/luarocks install sys
$PREFIX/bin/luarocks install xlua
$PREFIX/bin/luarocks install image
$PREFIX/bin/luarocks install env

echo ""
echo "=> Torch7 has been installed successfully"
echo ""


echo "Installing nngraph ... "
$PREFIX/bin/luarocks install nngraph
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
echo "nngraph installation completed"

echo "Installing Xitari ... "
cd /tmp
rm -rf xitari
git clone https://github.com/deepmind/xitari.git
cd xitari
$PREFIX/bin/luarocks make
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
echo "Xitari installation completed"

echo "Installing Alewrap ... "
cd /tmp
rm -rf alewrap
git clone https://github.com/deepmind/alewrap.git
cd alewrap
$PREFIX/bin/luarocks make
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
echo "Alewrap installation completed"

echo
echo "You can run experiments by executing: "
echo
echo " ./run_cpu game_name"
echo
echo " or "
echo
echo " ./run_gpu game_name"
echo
echo "For this you need to provide the rom files of the respective games (game_name.bin) in the roms/ directory"
echo

当我测试代码时./run_gpu {game_name},我得到:

../torch/bin/luajit: error while loading shared libraries: libreadline.so.7: cannot open shared object file: No such file or directory

当我跑步时:

ldconfig -p | grep readline

我的版本是 6

libreadline.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libreadline.so.6
libreadline.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libreadline.so
libguilereadline-v-18.so.18 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libguilereadline-v-18.so.18
libguilereadline-v-18.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libguilereadline-v-18.so

但是我无法安装 libreadline7:

sudo apt-get install libreadline7-dev

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libreadline7-dev

我该如何安装 libreadline7?

答案1

您需要的文件/lib/x86_64-linux-gnu/libreadline.so.7由 软件包提供libreadline7,而不是 的任何版本。任何 Ubuntu 发行版中libreadline-dev都没有这样的软件包。libreadline7-dev

由于您已经安装了libreadline.so.6它及其相关版本,因此您可能正在使用 Ubuntu 16.04 或 14.04。该libreadline7软件包在 Ubuntu 18.04 中可用。因此,这里的直接答案是,您可以通过升级到或安装 18.04 来获得它。要检查,您可以运行

apt policy libreadline7

如果尚未安装,请运行

sudo apt update
sudo apt install libreadline7

如果您只想跳过此步骤,看看在承诺升级之前是否会遇到其他问题,或者您现在真的无法升级,您可以尝试一种非常肮脏的黑客方法(不推荐,但不是很危险)。这是创建一个指向旧版本库的符号链接,以便程序认为它正在使用libreadline.so.7并且实际上正在使用libreadline.so.6

sudo ln -s /lib/x86_64-linux-gnu/libreadline.so.6 /lib/x86_64-linux-gnu/libreadline.so.7

这可能会使程序运行。但它也可能神秘地崩溃,没有任何有意义的错误消息。如果您像这样保留符号链接,您从第三方来源安装的其他程序也可能无法报告缺少的依赖项并神秘地崩溃。您可能会忘记您做了什么,并想知道您的愚蠢系统出了什么问题,所以最好只尝试这样的事情进行测试。您随时可以删除符号链接libreadline.so.7以回到开始的地方。

答案2

要解决此依赖关系,您需要手动安装上述软件包。前往 Ubuntu 商店并搜索该软件包。

https://packages.ubuntu.com/search?suite=default§ion=all&arch=any&keywords=libreadline7&searchon=names

这将列出软件包信息。单击软件包描述中提供的超链接。在本例中:

https://packages.ubuntu.com/bionic/libreadline7

点击您所在地区的任意链接。这将开始下载该软件包的 Debian 文件。

获得 Debian 文件后,只需使用以下dpkg命令即可安装。例如:

sudo dpkg -i Desktop/libreadline7_7.0-3_amd64.deb

相关内容