无法使用Perl在@INC中找到DBI.pm

时间:2015-06-09 14:33:17

标签: linux perl

我是Perl的新手,我安装了DBI模块但是当我尝试运行我的脚本时出现此错误:

Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains:
    /usr/lib/x86_64-linux-gnu/perl5/5.20/DBI.pm
    /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1/x86_64-linux
    /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/lib/site_perl/5.20.1
    /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/x86_64-linux
    /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1
    .
    ) at call_request.pl line 12.

[添加换行符以提高可读性]

我知道还有另一个主题是同一主题,但没有答案。我不知道我能做什么..?

我在linux上(ubutunu)

感谢您的帮助!

编辑:

输出:

perl est /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/bin/perl

cpan est /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/bin/cpan

#!/home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/bin/perl
    eval 'exec /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/bin/perl -S $0 ${1+"$@"}'
    if $running_under_some_shell;

grep arg
    make_arg           []
    make_install_arg   []
    makepl_arg         [INSTALLDIRS=site]
    mbuild_arg         []
    mbuild_install_arg []
    mbuildpl_arg       [--installdirs site]

PERLBREW_PERL: perl-5.20.1
PERLBREW_VERSION: 0.73
PERLBREW_ROOT: /home/heisenberg/perl5/perlbrew
PERLBREW_MANPATH: /home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/man
PERLBREW_HOME: /home/heisenberg/.perlbrew
PERLBREW_BASHRC_VERSION: 0.73
PERLBREW_PATH: /home/heisenberg/perl5/perlbrew/bin:/home/heisenberg/perl5/perlbrew/perls/perl-5.20.1/bin
PERL5LIB: /usr/lib/x86_64-linux-gnu/perl5/5.20/DBI.pm

1 个答案:

答案 0 :(得分:5)

您需要使用您想要的perl安装DBI。你说你已经这样做了,但事实显然并非如此。通常,你会做以下事情,但也许你有一个混乱的系统

perlbrew use perl-5.20.1
cpan DBI

如果这不起作用,请将以下输出添加到您的问题中,并通过发表评论通知我您已完成此操作。

perlbrew use perl-5.20.1
type perl
type cpan
head -n 3 "$( type -p cpan )"
echo "o conf" | cpan | grep arg
perl -E'say "$_: $ENV{$_}" for grep /^PERL/, keys %ENV'

PS - 无论您将/usr/lib/x86_64-linux-gnu/perl5/5.20/DBI.pm添加到@INC所做的一切都是错误的!摆脱它。

问题是由使用su导致的,这会导致系统perl被用来代替perlbrew - 已安装perl