Can't locate DBI.pm in @INC with Perl

9.2k Views Asked by At

I'm new in Perl, I installed the DBI module but when I try to run my script I get this error:

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.

[Line breaks added for readability]

I know there is another topic with the same subject but no answer. I have no idea what I can do.. ?

I'm on linux (ubutunu)

Thanks for help !

Edit :

Output :

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

There are 1 best solutions below

13
On BEST ANSWER

You need to install DBI using the perl for which you want available. You said you've already done this, but that's obviously not the case. Normally, you'd do the following, but maybe you have a messed up system

perlbrew use perl-5.20.1
cpan DBI

If that doesn't work, add the output of the following to your question and notify me you've done this by leaving a comment.

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 - Whatever you did to add /usr/lib/x86_64-linux-gnu/perl5/5.20/DBI.pm to @INC is wrong! Get rid of it.


The problems were caused by the use su, which would cause the system perl to be used instead of the perlbrew-installed perl.