1

I have an issue on including the Excel-Writer-XLSX module in the @INC path. I did some research before posting this question and tried several solutions, but they all failed.

So I did

$sudo perl -MCPAN -e 'install Excel::Writer::XLSX'

But after I run the code, I got this message

--can't locate Excel/Writer/XLSX.pm in @INC(you may need to install the Excel::Writer::XLSX module) (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level/...)

This is not a duplicate question, because the Excel::Writer::XLSX module has been successfully installed in my computer and I don't need to install it again. The thing is when I checked my library folder, the perl5 folder is not there, as it was suggested by the @INC path. Instead, Perl5 folder is in my user folder...and actually the module can be found in the lib folder inside the perl5 folder

I'm not quite sure what is happening...Why the @INC path shows the perl/5.18 is inside the library folder? If you know how to solve this issue, please advice. Thank you so much!

Penny
  • 1,218
  • 1
  • 13
  • 32
  • My question doesn't have an answer from the question showed above, because clearly the module has been installed in my computer. It's just the @INC path seem to be weird and can't find the module. – Penny Aug 26 '15 at 07:08
  • 1
    What would make this easier to resolve: `use Data::Dumper; print Dumper \%INC`. A perl version (e.g. is it 5.18?). Output of `which cpan` and `which perl`. – Sobrique Aug 26 '15 at 08:35
  • "when I checked my library folder, the perl5 folder is not there, as it was suggested by the @INC path. Instead, Perl5 folder is in my user folder" This sounds like you configured cpan to [bootstrap local::lib](https://metacpan.org/pod/CPAN#pod5). – ThisSuitIsBlackNot Aug 26 '15 at 14:19

2 Answers2

0

Make sure the @INC contains the path where your modules are getting installed. You can specify that by

export PERL5LIB=/home/foobar/code (For Linux) (Add this to ~/.bashrc to make it always available when you log-in.)

set PERL5LIB = c:\path\to\dir (For Windows)


Also see:

Community
  • 1
  • 1
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
  • I would still find out what is wrong first. I had a similar problem with a messed up perlbrew installation, and simply setting the path may not solve all problems, this unexpected '/library' path may hint at other problems. Do what Sobrique said and figure out what is wrong. – bytepusher Aug 26 '15 at 10:02
  • Thank you guys for the help! I will try it out! – Penny Aug 30 '15 at 02:47
0

At the very top of your perl code right after #!/usr/bin/perl

BEGIN
{
push(@INC, '/home/penny/perlModules');
}
use my::module;
use File::Path;
...

This will allow your code to use any module you've installed in perlModules dir.

Downside is you have to modify code. Or you can use PERL5LIB env path as answered above.

Rob
  • 51
  • 1
  • 9