我如何安装模块? 草莓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:strawberrycpansourcesauthors1mailrc.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:strawberrycpansourcesauthors1mailrc.txt.gz.tmp5264'. Giving up on it.
Warning: no success downloading 'C:strawberrycpansourcesauthors1mailrc.txt.gz.tmp5264'. Giving up on it.

As a last resort we now switch to the external ftp command 'C:WINDOWSsystem32ftp.EXE'
to get 'C:strawberrycpansourcesauthors1mailrc.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:WINDOWSsystem32ftp.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:strawberrycpansourcesauthors
    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:strawberrycpansourcesauthors.
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:strawberrycpansourcesauthors1mailrc.txt.gz.tmp5264'. Giving up on it.
Warning: no success downloading 'C:strawberrycpansourcesauthors1mailrc.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:strawberrycpansourcesauthors1mailrc.txt.gz.tmp5264'. Giving up on it.
Warning: no success downloading 'C:strawberrycpansourcesauthors1mailrc.txt.gz.tmp5264'. Giving up on it.

As a last resort we now switch to the external ftp command 'C:WINDOWSsystem32ftp.EXE'
to get 'C:strawberrycpansourcesauthors1mailrc.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:WINDOWSsystem32ftp.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:strawberrycpansourcesauthors
    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:strawberrycpansourcesauthors.
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

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

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

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

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

  • 如果代理配置很简单,您可以查看您的浏览器。
  • 如果它更复杂,你将不得不
  • 将URL粘贴到浏览器地址中的配置脚本中
  • 当浏览器提示你时(或者使用带有http URL的编辑器,如jEdit或Notepad ++),用编辑器打开该URL。
  • 一旦你解析你的位置和CPAN的情况,那么你可以取回服务器名称,一个端口(如果有的话),并使用该值设置环境变量或cpan配置。


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

    环境变量是:

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

    由于您在Windows上,因此您可以从相同的命令行界面执行以下操作:

    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协议)。

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

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


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

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

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

    另外,在管理CPAN再次运行之前,我使用了一个临时解决方法,即从我已升级Perl的机器上复制libsitevendor目录,并且CPAN仍在其中工作。 这样,我没有CPAN需要的所有模块都能正常工作。 (这两台机器是相同的架构,需要升级相同的安装程序。)

    链接地址: http://www.djcxy.com/p/47201.html

    上一篇: How do I install a module? Strawberry Perl issues

    下一篇: Should I choose ActivePerl or Strawberry Perl for Windows?