简体   繁体   中英

Installed Module not contained in the Perl's @INC path

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!

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM