in reply to Re: Can't locate LWP/UserAgent.pm
in thread Can't locate LWP/UserAgent.pm

I typed which perl at the command prompt and got /usr/opt/bin/perl.

I changed the first line of my script to
#!/usr/opt/bin/perl -w
and tried running it again. I got the same error message:

 Can't locate LWP/UserAgent.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.0/sun4-solaris-thread-multi /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris-thread-multi /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .) at weather.pl line 9.  BEGIN failed--compilation aborted at weather.pl line 9.

The script continues to work on the web page.

Replies are listed 'Best First'.
Re: Re: Re: Can't locate LWP/UserAgent.pm
by alienhuman (Pilgrim) on Aug 05, 2003 at 15:04 UTC

    K,

    It looks as though @INC for you doesn't include a version of perl with LWP::UserAgent.pm installed, whereas @INC for the webserver (usually 'nobody') does use a version of perl with the module.

    First off, run this cmd: locate perl | more That will show you all the places where perl is installed on the machine. My suspicion is that you have two versions of perl installed: 5.8.x is installed for users, and the web server is using some other version. If so, you'll see this kind of thing (minus my comments w arrows):

    ... /usr/lib/perl5/5.6.0 <--- version 5.6.0 of perl ... /usr/local/lib/perl5/5.6.1/CGI.pm <--- diff version --More--

    Edit: I didn't notice that you said the webserver is using 5.005x. Teach me not to read carefully.

    You (meaning your user account) seems to be using 5.8.x, which has no LWP::UserAgent.pm installed.

    You haven't said why you've decided to test this CGI script by running it from the command line, but you might consider using CGI::Carp, which will send error messages to the browser. And since it will be running as the web server, it will execute using the 5.005x version of perl that has LWP.

    Another solution is to remove the 5.8x version of perl from your $PATH variable, and add the 5.005x version. To do so, you'll have to find the 5.005x version--use 'locate perl | grep "5.005" | more; or something similar, and add the path to the 5.005 interpreter to your $PATH.

    AH

      Thank you for all the suggestions. I'm not an administrator and the server is in a different state, so this is a little beyond my knowledge, but I'm talking to one of the people in charge of the server.

      I do have use CGI::Carp 'fatalsToBrowser'; in my script and no errors show up in the browser.

      I just like testing it from the command line because that's where I do the programming and it's quick and easy. Also, the system it is on is a replicated distributed file system (using AFS). It replicates to multiple web servers every 15 minutes, so it takes up to 15 minutes for the script to work in my browser when connecting to the web site. I can force it to replicate, but it would just be quicker to test it at the command prompt.

        Boy, that is strange. I don't know what would cause fatalsToBrowser not to work--unless of course perl can't find the CGI module.

        It looks like you'll have to stick with running it on the command line. Have you tried changing your path to point to 5.005x version of perl, instead of 5.8? That's probably a good first step.

        Another thing to try is run it using perl -c yourscript.pl. That will show you the compilation errors right at the command line. Once you get those cleared up (by installing missing modules, etc, you'll be in better shape to start testing that script.

        I'd still recommend running it from a browser though--there might be problems that come up when running it from the webserver that don't from the commandline, and vice versa. Also, you avoid spending your time on problems that are not an issue when it's run as a CGI script.

        AH

      Make sure your perl /usr/bin/perl pointing to correct version cd /usr/bin perl -> ../perl5/5.8.4/bin/perl rm perl ln -s perl /usr/local/bin/perl5.12.0 started working
Re^3: Can't locate LWP/UserAgent.pm
by Anonymous Monk on Jul 14, 2008 at 09:14 UTC
    for this install libwww-perl this will fix it ask Admin to do it
      Hello people from 2008, I'm from the future. This solution was very helpful nevertheless, cheers!
      hx for the solution, it's working much better with this lib now ;)
        Can you tell me from where you got the library from. I am also facing the same issue. Narayan