如何在 perl 中安装 parallel-forkmanager

Posted

技术标签:

【中文标题】如何在 perl 中安装 parallel-forkmanager【英文标题】:How to install Parallel::ForkManager in Perl? 【发布时间】:2013-04-16 06:22:37 【问题描述】:

我厌倦了使用 perl 脚本并行运行多个作业,该脚本使用 parallel:ForkManager。

#!/usr/bin/perl  -w

use Parallel::ForkManager;

my @make_obj = qw(
 mode1_testlist
 mode1_testlist1
 mode1_testlist2
);

my $fm = $pm = Parallel::ForkManager-> new(3);
foreach my $obj (@make_obj) 
  $fm->start and next;
  print("make regression MODE=1 MODELIST=$make_obj");
  $fm->finish();

但它使我陷入错误。

无法在 @INC 中找到 Parallel/ForkManager.pm(@INC 包含:/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/ site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/ perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) 在 parallel_run.pl 第 3 行。 BEGIN 失败——编译在 parallel_run.pl 第 3 行中止。

我已经下载了 Parallel-ForkManager-1.03.tar.gz 但我不知道放在哪里我的意思是如何安装它。

我试过 perl Makefile.PL && make test && make install

WARNING: META_MERGE is not a known parameter.
WARNING: BUILD_REQUIRES is not a known parameter.
WARNING: LICENSE is not a known parameter.
Checking if your kit is complete...
Looks good
'BUILD_REQUIRES' is not a known MakeMaker parameter name.
'LICENSE' is not a known MakeMaker parameter name.
'META_MERGE' is not a known MakeMaker parameter name.
Writing Makefile for Parallel::ForkManager
cp lib/Parallel/ForkManager.pm blib/lib/Parallel/ForkManager.pm
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"test_harness(0,'blib/lib', 'blib/arch')" t/*.t
                                                                                            t/00-load.............ok 1/3    (in cleanup) Undefined subroutine 
&File::Path::remove_tree called at /h/altera_dump2/vjain419/regression_flow_bck
/regression_flow/MSS1/hw/verif/top_/00e/tools/Parallel-ForkManager-1.03/blib
/lib/Parallel  /ForkManager.pm line 662.
t/00-load.............ok
t/01-utf8-all.........skipped
    all skipped: Need utf8::all for this test crashing on Windows
    t/02-callback.........Array found where operator expected at t/02-callback.t line
    21,at  end of line
    (Do you need to predeclare explain?)
    syntax error at t/02-callback.t line 21, near "explain @out"
   xecution of t/02-callback.t aborted due to compilation errors.
   # Looks like your test died before it could output anything.
   t/02-callback.........dubious                                                
    Test returned status 255 (wstat 65280, 0xff00)
     DIED. FAILED tests 1-2
    Failed 2/2 tests, 0.00% okay
    t/03-callback-data....Array found where operator expected at t/03-callback-data.t line 13, at end of line
    (Do you need to predeclare explain?)
   syntax error at t/03-callback-data.t line 13, near "explain @out"
   Execution of t/03-callback-data.t aborted due to compilation errors.
    # Looks like your test died before it could output anything.
    t/03-callback-data....dubious                                                
    Test returned status 255 (wstat 65280, 0xff00)
    DIED. FAILED test 1
    Failed 1/1 tests, 0.00% okay
   Failed Test          Stat Wstat Total Fail  Failed  List of Failed
   t/02-callback.t       255 65280     2    4 200.00%  1-2
   t/03-callback-data.t  255 65280     1    2 200.00%  1
   1 test skipped.
   Failed 2/4 test scripts, 50.00% okay. 3/6 subtests failed, 50.00% okay.
   make: *** [test_dynamic] Error 255 

【问题讨论】:

【参考方案1】:

随便用

cpan Parallel::ForkManager

或者,在确保已安装其依赖项(POSIX、Storable、File::Spec、File::Temp、File::Path 2.00 和 Test::More 0.81_01)后执行以下命令:

tar xvzf Parallel-ForkManager-1.03.tar.gz
cd Parallel-ForkManager-1.03
perl Makefile.PL && make test && make install

【讨论】:

它需要 File::Path 2.00 或更高版本,即使在 Makefile.PL 中没有指定版本。即使在 Makefile.PL 中指定了 0.80,它也需要 Test::More 0.81_01。 仅供参考,我不是该服务器的管理员。我需要并行运行一些工作!如果还有其他出路,比如一些脚本,请告诉我! 查看了这个 deps.cpantesters.org/… 的依赖关系,我认为你不需要安装所有依赖模块,因为它们是核心模块,所以它应该很容易与 perl 一起使用。 perl Makefile.PL && make test && make install 对我来说效果很好。当您运行此命令时,日志会显示什么内容? @SuvasishSarker 我已经通过添加错误日志来编辑我的问题,这是我在运行perl Makefile.PL && make test && make install时得到的@ 当我尝试安装 TEST:MORE make install 给我以下警告时!Warning: You do not have permissions to install into /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 114. Cannot forceunlink /usr/lib/perl5/5.8.8/Test/Builder.pm: Permission denied at /usr/lib/perl5/5.8.8/File/Find.pm line 924 我想我应该有管理员权限来安装它!【参考方案2】:

就像已接受答案中的一些 cmets 所暗示的那样,可能缺少依赖项。以下对我有用:

cpan 升级测试::More

cpan Parallel::ForkManager

【讨论】:

【参考方案3】:

你需要运行 dmake,而不是 make

perl Makefile.PL && dmake test && dmake install

参考:http://www.perlmonks.org/?node_id=946668

【讨论】:

以上是关于如何在 perl 中安装 parallel-forkmanager的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Windows 上的 Perl 中安装 ExtUtils::PkgConfig?

如何在 centos 7 perl v5.34.0 中安装 DBD-SQLite

如何在 OS X Yosemite 上的 Apache 2.4 中安装 mod_perl 2.0.9?

如何在 Red Hat Enterprise Linux 中安装 Net::SFTP perl 模块

在主目录中安装perl模块时出现问题

如何安装多个版本的perl