无法为perl找到Module / Build.pm

时间:2017-06-24 15:13:53

标签: perl

我不是perl专家(请参阅this page),但是对于使用包,我必须运行一些perl命令。该命令显示此错误

$ perl Build.PL
Can't locate Module/Build.pm in @INC (@INC contains: /home/mahmood/src/bioperl-1.6.1 /home/mahmood/src/ensembl/modules 
/home/mahmood/src/ensembl-compara/modules /home/mahmood/src/ensembl-variation/modules 
/home/mahmood/src/ensembl-funcgen/modules /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl 
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Build.PL line 20.
BEGIN failed--compilation aborted at Build.PL line 20.

我看到这个reply首先提供运行cpan Module::Build以修复该错误。当我运行该命令时,我看到一堆问题(文本向导),它会问我一个镜像网址。然后它以交互方式请求我允许安装软件包。似乎问题的默认答案具有这样的效果。我也没有找到哪个问题对此负责。请参阅pastebin的完整输出。

有没有办法自动安装模块,以便我可以将它放在脚本中以备将来使用。

更新:

似乎我必须输入cpan.org网址,但是在我之前的尝试中,我使用了镜像网站。我尝试了回复中提出的三个命令,但仍然得到同样的错误:

Please enter the URL of your CPAN mirror  http://www.cpan.org
Configuration does not allow connecting to the internet.
Current set of CPAN URLs:
  http://www.cpan.org
Enter another URL or RETURN to quit: []
New urllist
  http://www.cpan.org


Please remember to call 'o conf commit' to make the config permanent!


cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1]> o conf build_requires_install_policy yes
    build_requires_install_policy [yes]
Please use 'o conf commit' to make the config permanent!


cpan[2]> o conf prerequisites_policy follow
    prerequisites_policy [follow]
Please use 'o conf commit' to make the config permanent!


cpan[3]> o conf commit
commit: wrote '/home/mahmood/.cpan/CPAN/MyConfig.pm'

cpan[4]> quit
No history written (no histfile specified).
Lockfile removed.
mahmood@cluster:Bio-DB-HTS$ perl Build.PL
Can't locate Module/Build.pm in @INC (@INC contains: /home/mahmood/src/bioperl-1.6.1 /home/mahmood/src/ensembl/modules /home/mahmood/src/ensembl-compara/modules /home/mahmood/src/ensembl-variation/modules /home/mahmood/src/ensembl-funcgen/modules /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Build.PL line 20.
BEGIN failed--compilation aborted at Build.PL line 20.

2 个答案:

答案 0 :(得分:2)

如果要将Module :: Build安装到系统库中,那么使用几乎可以为您的系统提供的预构建软件包可能要容易得多。

如果您正在使用类似RedHat的Linux发行版,请尝试:

$ sudo yum install perl-Module-Build

(在较新版本的Fedora上尝试dnf而不是yum。)

如果您正在使用类似Debian的Linux发行版,请尝试:

$ sudo apt-get install libmodule-build-perl

答案 1 :(得分:0)

现在您已配置cpan,您可以更改配置以绕过要求您安装每个依赖项。

在命令行上(注意o个字符是字面的...它们不是点数):

cpan
o conf build_requires_install_policy yes
o conf prerequisites_policy follow
o conf commit

要在手动输入回复之前查看每个项目的说明,请执行以下操作:

cpan

o conf init build_requires_install_policy

When a module declares another one as a 'build_requires' prerequisite
this means that the other module is only needed for building or
testing the module but need not be installed permanently. In this case
you may wish to install that other module nonetheless or just keep it
in the 'build_dir' directory to have it available only temporarily.
Installing saves time on future installations but makes the perl
installation bigger.

You can choose if you want to always install (yes), never install (no)
or be always asked. In the latter case you can set the default answer
for the question to yes (ask/yes) or no (ask/no).

 <build_requires_install_policy>
Policy on installing 'build_requires' modules (yes, no, ask/yes,
ask/no)? [yes] 


o conf init prerequisites_policy

The CPAN module can detect when a module which you are trying to build
depends on prerequisites. If this happens, it can build the
prerequisites for you automatically ('follow'), ask you for
confirmation ('ask'), or just ignore them ('ignore').  Choosing
'follow' also sets PERL_AUTOINSTALL and PERL_EXTUTILS_AUTOINSTALL for
"--defaultdeps" if not already set.

Please set your policy to one of the three values.

 <prerequisites_policy>
Policy on building prerequisites (follow, ask or ignore)? [follow] 

设置好后,不要忘记做:

o conf commit

...保存更改。

现在运行:

cpan Module::Build

...最后,运行您的构建脚本:

./Build.PL