I am currently trying to create/generate a CSV file using one of three classes:
use Class::CSV;
use Text::CSV;
use Text::CSV_XS;
Though when I try and run it, to check my code I come up with the same error message:
Can't locate Class/CSV.pm in #INC (#INC contains: C:/Per/site/lib C:/Perl/lib .) at C:\Users\<DIRECTORY> - <DIRECTORY>.file.pl line1
I have tried searching for the files though I haven't had any luck. Has anyone else come up against this problem? I have looking in the Directory and the CSV.pm file does exists.
Assuming that Class::CSV is installed on your system, your library search path is incomplete. (Your error message lists C:/Per/site/lib as a search lib, which looks like a typo for C:/Perl/site/lib, which you might want to look into.)
You need to locate the correct CSV.pm file where the library is located. For example, if it's found in:
C:/Perl/lib/foo/Class/CSV.pm
Then you have one of the following options.
Modify the environment for Perl or the invocation so that this is set (assuming my Windows skill haven't expired completely, someone feel free to edit and correct if I get the syntax wrong):
PERL5LIB=%PERL5LIB%;C:/Perl/lib/foo
You can use the -I option to perl to add the path:
perl -IC:/Perl/lib/foo my-app.pl
You can use the use lib command in the program itself to add the search path:
use lib 'C:/Perl/lib/foo';
use Class::CSV;
# etc.
You probably don't have these modules installed.
run this in your shell
perl -MCPAN -e shell
then run
install Class::CSV
I'm assuming that you found these classes on CPAN
You can simply run the following command
perl -MCPAN -e 'install Class::CSV'
to run
install Class::CSV in CPAN shell.
Related
I have a script on Windows which uses multiple pure Perl modules from CPAN.
I am trying to ship this script without the need to reinstall those modules from CPAN using App::FatPacker.
I installed App::FatPacker ( up to date (0.010007) version ) on Portable Strawberry Perl 5.24 .
When I run the following command
fatpack pack myscript.pl > myscript.packed.pl
I get
syntax OK
but the fatlib is empty and when I run my script it fails.
I tried to use this script which does nothing but load Geo::IP::PurePerl
use strict;
use warnings;
use Geo::IP::PurePerl;
and run again this command :
fatpack pack myscript.pl > myscript.packed.pl
Then I ran myscript.packed.pl on another instance of Strawberry Perl 5.24, I get the following error:
Can't locate Geo/IP/PurePerl.pm in #INC (you may need to install the Geo::IP::PurePerl module
I tried to debug it by building step by step
The fatpack trace creates a trace list as expected, including Geo::IP::PurePerl
The fatpack packlists-for finished successfully but the fatlib is empty.
Any idea?
I would say that packlists-for isn't finding any .packlist files
The documentation for fatpack says this
packlists-for
$ fatpack packlists-for Module1 Module2 Module3
Searches your perl's #INC for .packlist files containing the .pm files for the modules requested and emits a list of unique packlist files to STDOUT.
These packlists will, in a pure cpan-installation environment, be all non-core distributions required for those modules.
Unfortunately most vendors strip the .packlist files so if you installed modules via e.g. apt-get you may be missing those modules; installing your dependencies into a local::lib first is the preferred workaround.
I think that's useful advice that may well fix your problem
When I run my perl program, i get the error, i have tried googling it, but i could not find a definitive easy to solve answer
C:\Users\mte>C:\Users\mte\Desktop\org11.pl
Can't locate org2.pm in #INC (you may need to install the org2 module) (#INC con
tains: C:/Perl64/site/lib C:/Perl64/lib .) at C:\Users\mte\Desktop\org11.pl line
2.
BEGIN failed--compilation aborted at C:\Users\mte\Desktop\org11.pl line 2.
the beginning of my code looks like this
use warnings;
use org22;
Either your perl path is incorrect/lacking, or the org22 module is not installed. Take a look at this post for more information on constructing an #INC. Make sure that the org22 module is installed (and if it isn't, that's likely the cause of this error.)
Edit:
If your module is not in #INC (the standard perl include path), and assuming that your module (for example) is located at C:\Some\Path\MyModule.pm, then:
use lib 'C:\Some\Path';
use MyModule;
# Rest of your code
You also may consider using a shebang line as the 1st line in your script:
#!/bin/perl
or
#!/usr/bin/env perl
This will help ensure a consistent experience based on which perl interpreter you are using, given updates, installations of other programs, etc.
I'm running Linux on an embedded system, specifically Yocto Linux on a Cyclone V FPGA. I'm able to use Perl in its most basic form, but I'm unable to load any Perl modules. For example, when trying to use the GetOpt::Long module, I get the following error
root#socfpga_cyclone5:/mnt/sdcard# ./test.pl
Can't locate Getopt/Long.pm in #INC (#INC contains:
/etc/perl
/usr/lib/perl/site_perl/5.14.2/
/usr/lib/perl/site_perl/5.14.2
/usr/lib/perl/vendor_perl/5.14.2/
/usr/lib/perl/vendor_perl/5.14.2
/usr/lib/perl/5.14.2/
/usr/lib/perl/5.14.2
/usr/local/lib/site_perl
/usr/lib/perl/5.14.2
.) at ./test.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.
Does anybody know how I can go about installing these modules? Do the modules depend on hardware architecture at all? Is it reasonable to just copy and paste the .pm files somewhere from some source (and where would I be able to find and download these .pm files)?
I know your question is more than two years old, but it's a good question and I'm sad that nobody has answered it.
The perl ecosystem is very large, and the disk footprint of a full-featured perl installation is a problem on embedded systems. For that reason only a minimal system is installed when you add perl to your image. Other perl modules are available as bitbake packages.
Most of the time you can figure out what packages a recipe offers from the recipe, but the perl recipe is very complicated. The easiest way to find out what packages are built by the perl recipe is to build it (bitbake perl) and then look in the packages-split directory, which you will find in your bitbake work directory. For my system (cortex A8) that looks something like this:
$ ls -1 /poky/build/tmp/work/cortexa8hf-vfp-neon-poky-linux-gnueabi/perl/5.20.0-r1/packages-split
perl
perl-dbg
perl-dev
perl-doc
perl-lib
perl-lib.shlibdeps
perl-misc
perl-misc.shlibdeps
perl-module-anydbm-file
perl-module-app-cpan
perl-module-app-prove
perl-module-app-prove-state
(...)
If the module you want is listed, just add it to IMAGE_INSTALL like this:
IMAGE_INSTALL += "\
perl \
perl-module-base \
perl-module-bytes \
perl-module-data-dumper \
perl-module-digest-md5 \
perl-module-file-spec \
perl-module-file-spec-functions \
perl-module-findbin \
perl-module-getopt-long \
(...)"
If you want a module that isn't already being build, you will need to make your own recipe for it using the cpan class. See the examples in poky/meta/recipes-extended/perl and /poky/meta/recipes-lsb4/perl.
Editorializing, I've not been very happy with using perl on embedded systems. The biggest issue is the deferral of dependency resolution until runtime. It's too easy to mess this up and end up with Can't locate foobar.pm in #INC errors.
Have a look at this thread: https://lists.yoctoproject.org/pipermail/yocto/2013-July/015198.html
It sounds like perl modules have been packaged by whatever other thing needed first, but someone is working on making them available separately.
Some modules could be installed by just copying; others require a compiler or other build steps first. You are best off using whatever tools the yocto project provides.
I'm trying to get the resolution,width,height of the images in the specific file.
I have the following code.
#use strict;
use Image::Info qw(image_info dim);
use File::List;
#perl2exe_include Image::Info::JPEG;
#perl2exe_include PerlIO;
my $file = <ImageFilePath>;
my $info = image_info($file);
my $res = $info->{resolution};
print "$$res[0]\n";
I have the Perl Version 5.16.3
I get the following error:
Can't locate Image/Info.pm in #INC (#INC contains: c:\program files\Perl\lib c:/program files/Perl/site/lib c:/program files/Perl/lib .) at Img_Res.pl line 3.
BEGIN failed--compilation aborted at Img_Res.pl line 3.
Can anyone give me the solution to this?
From the code part of question I am concluding that you are trying to create an executable using Perl2EXE, because you are using the line
#perl2exe_include Image::Info::JPEG;
and also assuming that you are running command
perl2exe c:\somepath\somescript.pl -o somescript.exe
The answer from #James Green is correct to an extent, however its incomplete (as in fails to explain his second bullet point).
You need to install "Image::Info" and any other modules that you are using (Use the answer from #James Green).
After installation, Open to windows explorer and locate the module that you just installed,
It will normally be in the following folders
"PERL_PATH\perl\lib"
"PERL_PATH\perl\site\lib"
"PERL_PATH\perl\vendor\lib"
Once you locate the module is installed in the one of the 3 locations above. Navigate to the location where Perl2EXE is installed.
PERL2EXE_PATH\perl2exe-XX.xx-Win\
Locate the folder with the current version of perl you are using. In your case the folder name should be
Win32-5.16.3 or Win64-5.16.3
Open the folder and locate the .conf file.
Edit the line with header libdir.
libdir=perl-Win32/site/lib;perl-Win32/lib;perl-Win32/vendor/lib;.
Ensure all the perl/lib directories are included in the search path.
Save it and rerun your command. This should work.
Sometimes even after all this the perl2exe command fails, this is due to the limitation of the program being able to decipher the qw command.
So to avoid this directly call the module (ex: use Module::Name;) in your code instead of using the qw.
You need to ensure you've done two things:
install the Image::Info module
make sure #INC includes the path to wherever you installed the module
I see you're on Windows, which means you're likely using either Strawberry Perl, or ActiveState's Perl. If you're using Strawberry Perl you should have some success following the directions on http://www.cpan.org/modules/INSTALL.html -- I believe ActiveState has its own built-in package manager, ppm, and to get started with that you'll want to look here: http://www.activestate.com/activeperl/ppm-perl-modules
How can I set where Perl looks for modules in Apache httpd.conf file on OSX?
I've installed several modules via CPAN, which were installed successfully in
/opt/local/lib/perl5/site_perl/5.8.9
I can verify this via perldoc perllocal
If I run perl -V on the command line, I get (among other dirs):
#INC:
/opt/local/lib/perl5/site_perl/5.8.9/darwin-2level
/opt/local/lib/perl5/site_perl/5.8.9
When I run a perl script as CGI via Apache, however, I get errors that the modules I'm useing can not be found. The list of dirs being included in #INC do not match my local perl configuration.
[error] [client 127.0.0.1] Can't locate Spreadsheet/ParseExcel.pm in #INC (
#INC contains:
/Library/Perl/Updates/5.8.8
/System/Library/Perl/5.8.8/darwin-thread-multi-2level
/System/Library/Perl/5.8.8
/Library/Perl/5.8.8/darwin-thread-multi-2level
/Library/Perl/5.8.8
/Library/Perl
/Network/Library/Perl/5.8.8/darwin-thread-multi-2level
...
How is #INC getting set when running perl as CGI on OSX - and how do I override it?
The initial value of #INC is hardcoded when perl is built, but it can be modified in a number of ways. The most convenient here are
SetEnv PERL5LIB ...
from within the Apache configuration, or using
use lib qw( ... );
from within the Perl script.
That said, it's not safe to use modules installed using Perl 5.8.9 with Perl 5.8.8 (although the other way around is safe). Even worse, one appears to be a threaded Perl and the other one isn't. Modifying #INC is simply not going to work.
You need to install the module using the same perl as the one you intend to use to run the script, or you must run the script using the same perl as the one used to install the module.