Perl 模块无法识别

Posted

技术标签:

【中文标题】Perl 模块无法识别【英文标题】:Perl modules not recognized 【发布时间】:2021-11-01 02:35:56 【问题描述】:

我正在尝试运行 unitas_1.7.8.pl,bioinformatic software available here。重要的是,我过去在这台 ubuntu 机器上成功使用过这个软件很多次。现在当我运行命令时

perl ~/scripts/unitas_1.7.0.pl -threads 24 -s homo_sapiens -i PCR_Primer_11_S11_L001_R1_001.trim.lng ...

我得到了错误

Perl module LWP::Simple is not installed on this machine!
Perl module Archive::Extract (in core since 2007-07-07) is not installed on this machine!
Perl modules are available for download at http://www.cpan.org/

If you have CPAN installed try the following:
 cpan
 install Archive::Extract
 exit

If you are on MAC or UNIX you should run cpan with sudo:
 sudo cpan
 install Archive::Extract
 exit

我已按照这些说明更新并重新安装了 cpan(尽管我知道它应该没问题),但没有出现明显问题。自从我上次成功使用 unitas 以来,我唯一能想到的变化是服务器在一个月前硬重启。

详情:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal
$ cpan --version
Loading internal logger. Log::Log4perl recommended for better logging
/home/user/miniconda3/bin/cpan version 1.64 calling Getopt::Std::getopts (version 1.12 [paranoid]),
running under Perl version 5.30.3.
  [Now continuing due to backward compatibility and excessive paranoia.
   See 'perldoc Getopt::Std' about $Getopt::Std::STANDARD_HELP_VERSION.]
Nothing to install!

$ type -p perl; perl -M5.010 -e'say "$_: $ENV$_" for sort grep /^PERL/, keys(%ENV)'; echo 'o conf' | cpan
/home/stewart/miniconda3/bin/perl
[...]
    make               [/usr/bin/make]
    make_arg           []
    make_install_arg   []
    make_install_make_command [/usr/bin/make]
    makepl_arg         [INSTALLDIRS=site]
    mbuild_arg         []
    mbuild_install_arg []
    mbuild_install_build_command [./Build]
    mbuildpl_arg       [--installdirs site]
[...]
$ perl -MLWP::Simple -E 'say $INC"LWP/Simple.pm"'
Can't locate LWP/Simple.pm in @INC (you may need to install the LWP::Simple module) (@INC contains: /home/stewart/miniconda3/lib/site_perl/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/site_perl/5.30.3 /home/stewart/miniconda3/lib/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/5.30.3 .).
BEGIN failed--compilation aborted.
$ head -n 1 "$( type -p cpan )"
#!/home/stewart/miniconda3/bin/perl
$ perl -MLWP::Simple -e'print "ok\n"'
Can't locate LWP/Simple.pm in @INC (you may need to install the LWP::Simple module) (@INC contains: /home/stewart/miniconda3/lib/site_perl/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/site_perl/5.30.3 /home/stewart/miniconda3/lib/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/5.30.3 .).
BEGIN failed--compilation aborted.

LWP::Simple 和 Archive::Extract 的当前状态

$ sudo cpan install LWP::Simple
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
  Database was generated on Tue, 07 Sep 2021 08:55:47 GMT
LWP::Simple is up to date (6.56).
$ sudo cpan install Archive::Extract
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
  Database was generated on Tue, 07 Sep 2021 08:55:47 GMT
Archive::Extract is up to date (0.88).
$ sudo cpan LWP::Simple
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
  Database was generated on Tue, 07 Sep 2021 08:55:47 GMT
LWP::Simple is up to date (6.56).

【问题讨论】:

请提供type -p perl; perl -M5.010 -e'say "$_: $ENV$_" for sort grep /^PERL/, keys(%ENV)'; echo 'o conf' | cpan的输出 “我已经按照这些说明更新并重新安装了 cpan ...” :他们不要求您重新安装 cpan,而是安装模块 @ 987654328@ 和Archive::Extract。你试过了吗? 我已经按照@ikegami 的要求添加了输出,我也尝试单独安装每个模块,但他们都回来说他们已经正确安装了。 ".. 他们都回来说他们已经正确安装了"perl -MLWP::Simple -E 'say $INC"LWP/Simple.pm"'的输出是什么 还有一个:head -n 1 "$( type -p cpan )" 【参考方案1】:

如果您已经拥有 Miniconda,那么您应该在隔离环境中使用 Bioconda 通道进行安装。您从 conda 安装的 Perl 正在干扰您的系统 CPAN 模块:

conda create -n unitas -c bioconda unitas
conda activate unitas

unitas.pl -threads 24 -s homo_sapiens -i PCR_Primer_11_S11_L001_R1_001.trim.lng ...

conda deactivate

【讨论】:

这实际上对我不起作用,即使在 conda 环境中,我也遇到了与以前相同的错误。如果我尝试安装模块或其他东西,我假设有一种方法可以在 conda 中进行故障排除。起作用的是像这样调用系统 perl:/usr/bin/perl5.30.0 ~/scripts/unitas_1.7.0.pl ...【参考方案2】:

除了直接从另一个目录(已经安装了它)调用 perl 之外,没有任何建议的解决方案对我有用。

/usr/bin/perl5.30.0 ~/scripts/unitas_1.7.0.pl ...

可能有一种方法可以切换使用 $PATH 调用此目录时使用的默认 perl,但我现在找到了这个解决方法。谢谢大家的帮助。

【讨论】:

以上是关于Perl 模块无法识别的主要内容,如果未能解决你的问题,请参考以下文章

perl 系统调用无法识别路径

Homebrew的公式无法识别

Golang 无法识别模块

模块无法识别索引变量[重复]

psycopg2 模块无法识别

PyCharm 无法识别已安装的模块