如何安装模块?草莓Perl问题

时间:2011-07-07 13:30:22

标签: perl module cpan strawberry-perl

我正在尝试在Windows 7上的Strawberry Perl中安装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 win32-vanilla@perl.org
    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 win32-vanilla@perl.org
    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

4 个答案:

答案 0 :(得分:19)

这很容易发生防火墙/代理问题。您需要在http_proxy中设置cpan变量。 在shell命令提示符下键入cpan,然后按Enter键进入cpan shell。进入cpan shell后,输入以下内容:

o conf http_proxy http://proxy.mycorp.com:8080/
然后,

cpan可能会要求您输入用户名和密码,以便至少可以使用代理进行http流量。

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

  • 如果代理配置很简单,您可以查看浏览器。
  • 如果它更复杂,你必须这样做
    • 将网址粘贴到浏览器地址
    • 中的配置脚本
    • 在浏览器提示您时使用编辑器打开该URL(或使用带有http网址的编辑器jEditNotepad++。)。

解析了您的位置和CPAN的大小写后,您可以获取返回的服务器名称,端口(如果有),并使用该值设置环境变量或cpan配置。

答案 1 :(得分: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 :(得分:2)

我有类似的问题,虽然这里的解决方案并没有为我解决。我刚刚在三台机器上将Strawberry 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实际工作。 (这两台机器的架构相同,需要使用相同的安装程序进行升级。)

答案 3 :(得分:0)

Strawberry Perl环境中的CPAN配置文件是:

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

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

相关问题