I am running a Perl program that uses Math::Vector,
but I am getting the following error.
Can't locate object method "UnitVecPoints" via package "Math::Vector"
at /usr/local/share/perl5/Math/Vector.pm line 135.
How do I proceed? The module is correctly installed.
The module is no longer on CPAN. I found it on backpan, though: http://backpan.perl.org/authors/id/W/WS/WSYVINSKI/Vector.pm
It seems to call UnitVecPoints, but it only defines UnitVectorPoints. Try to edit the file /usr/local/share/perl5/Math/Vector.pm, providing the correct subroutine name.
Related
I have a perl program that uses WWW::Mechanize::Firefox on windows 7 32bit with strawberry perl.
It works fine with the command C:\>perl testcase.pl. When I compile it with C:\>pp -o testcase.exe testcase.pl it compiles with no errors.
When I run the testcase.exe it gives me the error:
Failed to connect to , Can't locate object method "setup" via package "MozRepl::Client" at MozRepl.pm line 224
The code I am using for testcase.pl is:
#!perl
use MozRepl;
use WWW::Mechanize::Firefox;
use warnings;
system('start firefox');
sleep(5);
$mech = WWW::Mechanize::Firefox->new;
Also note that a program without WWW::Mechanize::Firefox and MozRepl does work fine.
The problem has obviously been narrowed down to PAR::Packer not liking MozRepl, any idea what it might be?
PAR::Packer sometimes has a hard time identifying which modules need to be included in a PAR package in order to fulfill all of the requirements of the program you are trying to package.
It copes OK if the dependancies are loaded via plain 'use', or 'require' statements where the module to be loaded is a literal string, but it won't have much chance if the module is being loaded dynamically with something like:
require $myModuleToLoad;
Browsing the source code of MozRepl and related modules shows that they make heavy use of plugins loaded dynamically. I suspect that some of these are not being packaged.
You can manually specify module(s) to be included in the PAR package by adding -M Module::Name to the pp command line for each of the modules to be added (replacing Module::Name with the actual module name of course).
The hard part might be identifying which modules to include. One way to do this is to temporarily add something like this to the end of your script:
END { print "$_ -> $INC{$_}\n" foreach sort keys %INC; }
then run your script normally, not through PAR. It should list all the modules that were loaded. You can compare that with the actual modules present in the PAR package and add the missing ones using the -M option to pp.
You can see the modules inside your PAR file by opening it with an unzipping tool, such as 7zip. Or in Linux:
unzip -l {parfile}
I am trying to use a Win32 dll in a perl script using Win32::API module.
For this I have written a perl script like this
use Win32::API;
$Win32::API::DEBUG = 1;
$function = Win32::API->new(
'mydll.dll', 'int func()',
);
$return = $function->Call();
But I am getting the following error:
Win32::API::new: Loading library 'mydll.dll'
FAILED Loading library 'mydll.dll': The specified module could not be found.
Can't call method "Call" on an undefined value at .\test_dll.pl line 6.
Although the script and the dll are at the same location, so there is no way it can't find the dll. Also i have tried using the full path.
I am using active perl 5.16 on Windos 7 platform. I have tried this with 5.14 too without any help
What is happening here?
This is resolved after adding the other dependent dlls to the same place as it is .
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
I have inherited a web project that is perl based and I'm attempting to set up a local testing server so changes can be made internally to the project.
The server architecture
Ubuntu 9.10
php 5.2.10
mysql 5.1.37
perl 5.10.0-24ubuntu4
All the dependent modules and packages are installed such as DateTime.pm, TemplateToolkit.pm but running the application throws the following error message:
Can't locate object method "new" via package "Template" (perhaps you forgot to load "Template"?) at ../lib//KPS/TemplateToolkit.pm line 51
The code block that this refers to is:
sub new {
return Template->new(
INCLUDE_PATH => $KPS::Config::templatepath,
ABSOLUTE => 1,
DEBUG => 1,
);
}
If anybody is able to shed any light on this or point me in the right direction it would be greatly appreciated.
Thanks
Simnom
You need to load Template Toolkit first, with:
use Template;
To make sure that Template::Toolkit is properly installed on this system, from a console you could run:
perl -MTemplate -e0
If it returns without an error, it means Template.pm wsa loaded succesfully; if not, it will give you an error of "Can't locate Template.pm in #INC...".
An additional thing to check because the accepted answer test could be successful even if you are not setup correctly; make sure that the package declaration in the module has the correct path. The scenario is as follows:
You do
use a::b;
...
a::b->new();
and then in b.pm you do
package b;
You may be banging your head for a while until you realize that you need to do
package a::b;
I ran into this problem when trying to run a command via Net::SSH:Perl on another Linux host. Here is the exact error:
`as_number' is not a Pari function name Line 1148.
5.8.8/x86_64-linux-thread-multi/Math/Pari.pm
I found only one relevant posting and it indicates that it could be some sort of version mismatch between some of the Perl libraries?
See this question: How do I fix “`as_number’ is not a Pari function name” in Math::Pari called by Math::BigInt?.