Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't locate LWP/Simple.pm in @INC [duplicate]

Tags:

perl

Possible Duplicate:
What's the easiest way to install a missing Perl module?

I'm attempting to run a Perl script to convert SCXML to Graphviz DOT. I modified the first line of the script to:

#!/usr/bin/env perl

and chmod +x the file. When I run it via ./scmxl2dot.pl I see the following error output:

Can't locate LWP/Simple.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/site_perl/5.12.3 /opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.3 /opt/local/lib/perl5/5.12.3/darwin-multi-2level /opt/local/lib/perl5/5.12.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at ./scmxml2dot.pl line 14.
BEGIN failed--compilation aborted at ./scmxml2dot.pl line 14.

Line 14 of the file is use LWP::Simple;

How do I:

  1. Find out if I have this thing (module?) installed, and/or
  2. Get LWP::Simple and make it available to the script?

This is running under OS X 10.7.3 and Perl 5.12.3 (as seen in the error).

like image 599
Phrogz Avatar asked May 09 '12 22:05

Phrogz


3 Answers

  1. You're already determined that you don't have it (somewhere it can be found).

  2. perl -MCPAN -e'install "LWP::Simple"'

like image 199
ikegami Avatar answered Oct 30 '22 03:10

ikegami


  1. Execute the following from the command line:

    perl -MLWP::Simple -e 1
    

    If you don't get any output from the above command then the module is installed; if you get an error, it's not installed

  2. to install use

    perl -MCPAN -e'install "LWP::Simple"'
    

When perl encounters use My::Module it goes over the elements of the built-in @INC module that contains directory names. In each directory it check if there is a subdirectory called "My" and if in that subdirectory there is a file called "Module.pm".

check where LWP::Simple module is installed on your system and type below line just above the use LWP::Simple statement of your code.

    use lib '/usr/local/module';
    use LWP::Simple;
like image 35
Sunil Kartikey Avatar answered Oct 30 '22 03:10

Sunil Kartikey


Take a look at the Perldoc webpage. This will tell you which modules are standard Perl modules and which ones aren't.

You can also use the perldoc command to find out if a Perl module is installed, and if it is, its documentation.

$ perldoc LWP::Simple

(If Perldoc doesn't execute as a command do ls -l /usr/bin/perl*. On Macs, some of the Perl commands don't have the execute bit turned on. To turn it on, do sudo chmod a+x /usr/bin/perl).

It just happens the LWP::Simple isn't a standard Perl module, and if you don't have it, you'll have to install it. Most people have already told you about cpan. Unfortunately, by default, the Mac doesn't have the needed command line development tools installed. You'll have to install them.

Once they're installed, you can use the cpan command to install LWP::Simple:

$ sudo cpan   #Run cpan and configure it. It takes about 3 minutes
cpan> install LWP::Simple
cpan> exit
like image 38
David W. Avatar answered Oct 30 '22 03:10

David W.