问题
Been running in Google'ish circles trying to install XML::XPath on windows. Windows 10, Perl 5.4 (where perl = /usr/bin/perl).
I am running Strawberry perl. "cpan install XML::XPath" fails,
> cpan install XML::XPath
Can't find E:\Plang\Strawberry_Perl\perl\bin\cpan.bat on PATH, '.' not in PATH.
Manual download of xml-xpath-1.44, then unpacking, and run makefile, fails:
perl Makefile.PL
Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel'...
So I went to the site: http://sourceforge.net/projects/expat/ and downloaded and ran:
expat-win32bin-2.2.9.exe
and ran it, and then ran the recommended revised Makefile command:
perl Makefile.PL EXPATLIBPATH=e:/plang/expat/lib EXPATINCPATH=e:/plang/expat/include
but xml-parser Makefile still fails in the same way.
Seems like it should be easier than this; maybe I am missing something?
(Strawberry perl installed from their site latest .msi file = 5.30.) C:\Users\guthrie>which cpan /e/Plang/Strawberry_Perl/perl/bin/cpan
(pip comment; sorry, simultaneously trying this on Python!)
回答1:
Strawberry Perl's cpan.bat
uses the first perl
in the path. You are using an MSYS build of Perl rather than the Strawberry Perl build for which you want to install the module.
Solution 1
Move Strawberry Perl earlier in the PATH.
Solution 2
Explicitly specify which perl
you want to use when executing cpan
.
E:\Plang\Strawberry_Perl\perl\bin\perl E:\Plang\Strawberry_Perl\perl\bin\cpan XML::XPath
Solution 3
Explicitly specify which perl
you want to use, and avoid the cpan
script in favour of using the underlying module directly.
E:\Plang\Strawberry_Perl\perl\bin\perl -MCPAN -e"CPAN::Shell->install(@ARGV)" XML::XPath
You are likely to run into further problems if you use the second and third solution, so I'd go with the first. It doesn't need to be a permanent change. In fact, you can simply changes the PATH in the console that will be used to install the module.
来源:https://stackoverflow.com/questions/63198776/how-to-install-perl-xmlxpath-on-windows