mowax has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying write a small script that can do OCR on images. So far I have this much
#!/usr/bin/perl use OCR::PerfectCR; use GD;
However, I get the error message:
Can't locate GD.pm in @INC (@INC contains: /etc/perl /usr/local/lib/pe +rl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl +5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) + at /usr/local/share/perl/5.10.0/OCR/PerfectCR.pm line 9.
When I launch CPAN and type "install GD" it comes back with "GD is up to date (2.41)". Which would suggest it's already installed. Anyone know why I'm getting this error on the script?

Thanks

Replies are listed 'Best First'.
Re: Can't locate GD.pm in @INC
by ig (Vicar) on May 06, 2009 at 22:45 UTC

    To find out where cpan has installed GD, use the "m" command and look for the "INST_FILE" item. This is the path where the module is installed. On my system, it looks as follows:

    cpan[8]> m GD Module id = GD DESCRIPTION Interface to Gd Graphics Library CPAN_USERID LDS (Lincoln D. Stein <lstein@cshl.edu>) CPAN_VERSION 2.41 CPAN_FILE L/LD/LDS/GD-2.41.tar.gz UPLOAD_DATE 2008-08-07 DSLIP_STATUS MdcOp (mature,developer,C,object-oriented,Standard-Pe +rl) MANPAGE GD.pm - Interface to Gd Graphics Library INST_FILE /usr/local/lib/perl5/site_perl/5.10.0/i686-linux/GD.p +m INST_VERSION 2.41

    As cpan sees that the module is installed but your script can't load it, it must be that cpan and your script are looking in different places. Your script will look in every folder listed in @INC, the contents of which are displayed in the error message you have posted.

    This can happen if you have two different instances of perl on your system. You may run one when you run cpan (which is a perl script) and a different one when you run your script producing the error.

      Hi, i have the same problem but perhaps different root cause, which I have not figured out yet. Appreciate monks' help... cpan1> m GD CPAN: Storable loaded ok (v2.20) Reading '/root/.cpan/Metadata' Database was generated on Tue, 21 Apr 2015 02:53:28 GMT Module id = GD CPAN_USERID LDS (Lincoln D. Stein <lincoln.stein@gmail.com>) CPAN_VERSION 2.56 CPAN_FILE L/LD/LDS/GD-2.56.tar.gz UPLOAD_DATE 2014-10-28 INST_FILE (not installed) cpan2> install GD::Graph CPAN: Module::CoreList loaded ok (v5.20150320) GD::Graph is up to date (1.49).
Re: Can't locate GD.pm in @INC
by przemo (Scribe) on May 06, 2009 at 20:29 UTC

    And can you find GD.pm in the mentioned @INC paths? If I'm guessing correctly, you are using some kind of Debian system; on this system the file should be placed in /usr/lib/perl5/GD.pm.

    If, however, you installed GD with CPAN, look inside /usr/local/lib/perl/5.10.0 (or /usr/local/share/perl/5.10.0 by accident).

Re: Can't locate GD.pm in @INC
by bichonfrise74 (Vicar) on May 07, 2009 at 00:35 UTC
    That's a nice trick. I've always typed help in the cpan shell and have always neglected what the display information means until today.