安装moses脚本期间出现问题

安装moses脚本期间出现问题

可能的重复:
/bin/sh: ./check-dependency.pl: 未找到 — 但 check-dependency.pl 存在!

编译时出现错误moses-script,内容如下:

minakshi@minakshi-Vostro-3500:~/Desktop/monu/moses/scripts$ make release
# Compile the parts
make all
make[1]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts'
# Building memscore may fail e.g. if boost is not available.
# We ignore this because traditional scoring will still work and memscore isn't used by default.
cd training/memscore ; \
      ./configure && make \
      || ( echo "WARNING: Building memscore failed."; \
           echo 'training/memscore/memscore' >> ../../release-exclude )
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for boostlib >= 1.31.0... yes
checking for cos in -lm... yes
checking for gzopen in -lz... yes
checking for cblas_dgemm in -lgslcblas... no
checking for gsl_blas_dgemm in -lgsl... no
checking how to run the C++ preprocessor... g++ -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking n_gram.h usability... no
checking n_gram.h presence... no
checking for n_gram.h... no
checking for size_t... yes
checking for ptrdiff_t... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
make  all-am
make[3]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
make[3]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/memscore'
touch release-exclude # No files excluded by default
pwd=`pwd`; \
    for subdir in cmert-0.5 phrase-extract symal mbr lexical-reordering; do \
      make -C training/$subdir || exit 1; \
      echo "### Compiler $subdir"; \
      cd $pwd; \
    done
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/cmert-0.5'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/cmert-0.5'
### Compiler cmert-0.5
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/phrase-extract'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/phrase-extract'
### Compiler phrase-extract
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/symal'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/symal'
### Compiler symal
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/mbr'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/mbr'
### Compiler mbr
make[2]: Entering directory `/home/minakshi/Desktop/monu/moses/scripts/training/lexical-reordering'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts/training/lexical-reordering'
### Compiler lexical-reordering
## All files that need compilation were compiled
make[1]: Leaving directory `/home/minakshi/Desktop/monu/moses/scripts'
/bin/sh: ./check-dependencies.pl: not found
make: *** [release] Error 127

我们不知道为什么会出现这个错误? check-dependency.pl 文件存在于脚本文件夹中...

答案1

我的预感:./check-dependencies.pl从 开始#!/usr/local/bin/perl。将第一行更改为#!/usr/bin/perl.

说明:当你运行一个程序时,内核将文件加载到内存中并执行它。然而,许多可执行文件(实际上是大多数)不能直接执行,而是需要另一个程序,即加载程序:

  • 大多数二进制程序都是动态链接的,并且必须由动态链接器/lib/ld-linux.so.2对于 32 位程序,/lib64/ld-linux-x86-64.so.2对于 64 位程序)负责加载程序请求的库。
  • 脚本必须由其解释器加载。

内核识别脚本是因为它以舍邦线。 shebang 行是脚本的第一行,由字符组成#!,后跟解释器的完整路径。 (可选)该行还可以包含一个空格,后跟一个传递给解释器的参数。

例如,如果脚本以 开头#!/usr/local/bin/perl -w,那么当内核被告知执行该脚本时,它会执行/usr/local/bin/perl -w /path/to/script。如果它无法执行/usr/local/bin/perl,您会收到一条错误消息。由于内核只能报告错误代码而无法报告其他信息,因此如果脚本不存在或解释器不存在,则来自内核的信息是相同的。

在这种情况下,某些 shell 会仔细检查错误情况,并在脚本存在但内核报告“找不到文件”时打印不同的消息,例如“错误的解释器”。但是 Ubuntu ( ) 上的默认脚本 shell/bin/sh是 Dash,该 shell 旨在快速执行脚本,并且没有像这样的额外便利功能。所以你会得到简单的“文件未找到”报告。

许多 Perl 脚本都以 开头#!/usr/local/bin/perl,这是大多数非 Linux 安装上 Perl 的路径。您可能会发现在您的计算机上创建它很有帮助 - 使其成为 的符号链接/usr/bin/perl,并在您使用它时对其他解释器执行相同的操作。

cd /usr/local/bin
ln -s ../../../bin/bash ../../bin/perl ../../bin/python ../../bin/ruby .

当您编写脚本时,可以通过编写像 这样的 shebang 行来避免此问题#!/usr/bin/env perl。仅当您不将参数传递给解释器时才能完成此操作。看为什么使用“#!/usr/bin/env NAME”而不是“#!/path/to/NAME”作为我的 shebang 更好?来讨论这种可能性。

相关内容