Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Can't locate LWP/UserAgent.pm

by larsen (Parson)
on Aug 05, 2003 at 14:29 UTC ( #280990=note: print w/ replies, xml ) Need Help??


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

I'm a bit confused. Here what I've understood: there's a CGI script that has some problems, so you tried it from the command line, where it gives compilation errors due to lack of LWP::UserAgent. My suspect is that you have two version of Perl on that machine. One is /usr/bin/perl, which is used by the script when run through the webserver, and the other one is /usr/local/bin/perl, which is being called when you type perl from the command line. The latter has not LWP::UserAgent installed. You can verify my suspect typing:

which perl

at the command prompt.


Comment on Re: Can't locate LWP/UserAgent.pm
Select or Download Code
Re: Re: Can't locate LWP/UserAgent.pm
by kryberg (Pilgrim) on Aug 05, 2003 at 14:41 UTC
    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.

      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.
        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
      for this install libwww-perl this will fix it ask Admin to do it
        hx for the solution, it's working much better with this lib now ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://280990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2014-09-22 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (180 votes), past polls