2011-07-07 78 views
15

我想在Windows上的草莓Perl中安装一个Perl模块  7.如何安装模块?草莓Perl问题

我正在运行下面的命令,并得到一堆我不明白的消息。它看起来像我得到500错误,就好像该页面无法访问。但是,当我将镜像指向浏览器时,访问FTP目录时没有问题。我在Linux上有很少的Perl经验,而在Windows上没有。我试图手动添加一个镜像到urllist,我不认为这有帮助。

C:\Program Files> cpan Win32::IE::Mechanize 

CPAN: LWP::UserAgent loaded ok (v5.835) 
CPAN: Time::HiRes loaded ok (v1.9721) 
Fetching with LWP: 
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz 
LWP failed with code[500] message[Can't connect to cpan.strawberryperl.com:80 (Bad hostname 'cpan.strawberryperl.com')] 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 
Fetching with LWP: 
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz 
LWP failed with code[500] message[LWP::Protocol::MyFTP: Bad hostname 'mirror.teklinks.com'] 
Fetching with Net::FTP: 
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz 
    Could not connect to host 'mirror.teklinks.com' with Net::FTP 
Fetching with Net::FTP 
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz.gz 
    Could not connect to host 'mirror.teklinks.com' with Net::FTP 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 

As a last resort we now switch to the external ftp command 'C:\WINDOWS\system32\ftp.EXE' 
to get 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. 

Doing so often leads to problems that are hard to diagnose. 

If you're the victim of such problems, please consider unsetting the 
ftp config variable with 

    o conf ftp "" 
    o conf commit 

Issuing "C:\WINDOWS\system32\ftp.EXE -n" 

    Trying with external ftp to get 
    ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz 
    Going to send the dialog 
    open mirror.teklinks.com 
    user anonymous [email protected] 
    lcd C:\strawberry\cpan\sources\authors 
    cd/
    cd CPAN 
    cd authors 
    bin 
    passive 
    get 01mailrc.txt.gz 01mailrc.txt.gz.tmp5264 
    quit 

Unknown host mirror.teklinks.com. 
Not connected. 
Local directory now C:\strawberry\cpan\sources\authors. 
Not connected. 
Not connected. 
Not connected. 
Not connected. 
Invalid command. 
Not connected. 
Bad luck... Still failed! 
Can't access URL ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz. 

Fetching with LWP: 
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz 
LWP failed with code[500] message[Can't connect to cpan.strawberryperl.com:80 (Bad hostname 'cpan.strawberryperl.com')] 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 
Fetching with LWP: 
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz 
LWP failed with code[500] message[LWP::Protocol::MyFTP: Bad hostname 'mirror.teklinks.com'] 
Fetching with Net::FTP: 
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz 
    Could not connect to host 'mirror.teklinks.com' with Net::FTP 
Fetching with Net::FTP 
ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz.gz 
    Could not connect to host 'mirror.teklinks.com' with Net::FTP 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 
Warning: no success downloading 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. Giving up on it. 

As a last resort we now switch to the external ftp command 'C:\WINDOWS\system32\ftp.EXE' 
to get 'C:\strawberry\cpan\sources\authors\01mailrc.txt.gz.tmp5264'. 

Doing so often leads to problems that are hard to diagnose. 

If you're the victim of such problems, please consider unsetting the 
ftp config variable with 

    o conf ftp "" 
    o conf commit 

Issuing "C:\WINDOWS\system32\ftp.EXE -n" 

    Trying with external ftp to get 
    ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz 
    Going to send the dialog 
    open mirror.teklinks.com 
    user anonymous [email protected] 
    lcd C:\strawberry\cpan\sources\authors 
    cd/
    cd CPAN 
    cd authors 
    bin 
    passive 
    get 01mailrc.txt.gz 01mailrc.txt.gz.tmp5264 
    quit 

Unknown host mirror.teklinks.com. 
Not connected. 
Local directory now C:\strawberry\cpan\sources\authors. 
Not connected. 
Not connected. 
Not connected. 
Not connected. 
Invalid command. 
Not connected. 
Bad luck... Still failed! 
Can't access URL ftp://mirror.teklinks.com/CPAN/authors/01mailrc.txt.gz. 

CPAN: YAML loaded ok (v0.73) 
Please check, if the URLs I found in your configuration file 
(http://cpan.strawberryperl.com/, ftp://mirror.teklinks.com/CPAN/) are 
valid. The urllist can be edited. E.g. with 'o conf urllist push 
ftp://myurl/' 

Could not fetch authors/01mailrc.txt.gz 
+0

这些看起来大多像代理/网络问题。你的网络配置是什么样的?你在防火墙后面吗? –

+0

我在公司的防火墙后面,我怀疑,但后来我可以通过浏览器访问它。 – Brian

+1

@Brian,是的,因为您的浏览器可能设置为正确使用并忽略代理 - 通常通过配置脚本。 – Axeman

回答

18

这很容易出现防火墙/代理问题。您需要在cpan中设置http_proxy变量。 在shell命令提示符处输入cpan并输入cpan shell。一旦在cpan外壳,输入以下内容:

o conf http_proxy http://proxy.mycorp.com:8080/ 

cpan可能会请你输入用户名和密码,这样就可以使用代理HTTP流量,至少。

您的ftp访问可能被防火墙阻止。 cpan将解决这个问题。

  • 如果代理配置很简单,您可以查看浏览器。
  • 如果是比较复杂的,你必须
    • 粘贴到浏览器地址的URL配置脚本
    • 打开与编辑URL时,浏览器会提示您(或使用编辑器需要http URL —,比如jEditNotepad++。)。

一旦你分析你的位置和CPAN的话,那么你可以把服务器名称返回,一个端口如果有的话,要么设置环境变量或值cpan配置。

+2

运行'o conf init/proxy /'查看/设置所有与代理相关的选项,而不仅仅是常用的HTTP代理。 – daxim

6

这看起来像一个代理问题。 cpan shell使用需要设置的环境变量,以便知道代理 - 它无法从浏览器中检测到它们。

的环境变量是:

http_proxy   proxy host for http requests 
ftp_proxy   proxy host for ftp requests 

由于您使用的是Windows,你可以做从同一命令shell执行以下操作:

C:\> set http_proxy=http://proxy.sn.no:8001/ 
C:\> set ftp_proxy=http://proxy.sn.no:8001/ 
C:\> cpan 

,然后尝试作为之前安装。由于您的CPAN使用的是FTP,因此需要设置ftp_proxy(并且是的,它的URL通常是HTTP)。

您还可以在系统控制面板中永久设置环境变量,通常在高级设置环境变量下。您可以为系统或当前用户设置它们。除非你有很好的理由,否则最好不要为整个系统设置它们。

你将不得不弄清代理实际是什么。你的浏览器应该知道,所以看看它的网络设置。

2

我有一个类似的问题,虽然这里的解决方案没有为我解决它。我刚刚在三台机器上将草莓Perl从5.18.2.1升级到了5.20.1.1,尽管CPAN在两台Windows 7机器上运行,但它并未在Windows Server 2003机器上运行。

最后,为我解决的事情是删除CPAN配置文件,C:\strawberry\perl\lib\CPAN\Config.pm在我的情况。我开始CPAN并做了reload index;它再次要求我提供我的凭据(我不需要使用我的代理),所以我只需要输入两次以将它们留空,并设法连接并更新其索引。

我记得以前看过Strawberry Perl发行说明中的​​警告,说删除C:\strawberry后卸载以前的版本和安装新版本之前。这一次似乎没有这样的警告,但无论如何,我认为这是很好的做法。

顺便说一句,我设法得到CPAN再次合作之前使用的临时解决方法是跨libsitevendor从目录上,我想升级的Perl已经是机上CPAN 复制做仍工作。这样,我没有CPAN需要的所有模块都能正常工作。 (两台机器都是一样的架构,也需要相同的安装程序进行升级。)

0

在草莓Perl环境的CPAN配置文件是:

c:\Strawberry\perl\lib\CPAN\Config.pm . 

为特定用户配置的定义都写在MyConfig.pm文件位于:C:\Users\user name\AppData\Local\.cpan\CPAN\。代理定义可以在其中一个文件中被覆盖。