2013-05-04 69 views
41

我有一个困难的时候使用pip来安装几乎任何东西。我是编程新手,所以我想也许这是我一直在做错的事情,并已选择easy_install来获取我需要完成的大部分工作,这一般起作用。但是,现在我正在尝试下载nltk库,而且还没有完成任务。pip问题安装几乎任何库

我试图进入

sudo pip install nltk 

,但得到如下回应:

/Library/Frameworks/Python.framework/Versions/2.7/bin/pip run on Sat May 4 00:15:38 2013 
Downloading/unpacking nltk 

    Getting page https://pypi.python.org/simple/nltk/ 
    Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm> 

    Will skip URL [need more reputation to post link]/simple/nltk/ when looking for download links for nltk 

    Getting page [need more reputation to post link]/simple/ 
    Could not fetch URL https://pypi.python. org/simple/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm> 

    Will skip URL [need more reputation to post link] when looking for download links for nltk 

    Cannot fetch index base URL [need more reputation to post link] 

    URLs to search for versions for nltk: 
    * [need more reputation to post link] 
    Getting page [need more reputation to post link] 
    Could not fetch URL [need more reputation to post link]: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm> 

    Will skip URL [need more reputation to post link] when looking for download links for nltk 

    Could not find any downloads that satisfy the requirement nltk 

No distributions at all found for nltk 

Exception information: 
Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main 
    status = self.run(options, args) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 266, in run 
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1026, in prepare_files 
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 171, in find_requirement 
    raise DistributionNotFound('No distributions at all found for %s' % req) 
DistributionNotFound: No distributions at all found for nltk 

--easy_install installed fragments of the library and the code ran into trouble very quickly upon trying to run it. 

在这个问题上有什么想法?我真的很感激我的一些反馈意见,我可以如何让pip工作或在此期间解决问题。

回答

28

您可能会看到this bug;另请参阅here

最简单的解决方法是将pip降级为不使用SSL的pip:easy_install pip==1.2.1。这会让您失去使用SSL的安全优势。真正的解决方案是使用链接到更新的SSL库的Python分发。

+1

感谢Dougal,但pip 1.2.1也无法解决。 - 请介意让我知道如何将我的python发行版更新为更新的ssl库? – contentclown 2013-05-04 05:33:10

+0

实际上,我刚刚得到了一切工作。谢谢你的帮助,Dougal! – contentclown 2013-05-04 05:49:03

+7

@ user2348946你做了什么,这对未来的人有用吗? – Dougal 2013-05-04 06:06:50

0

如果只是关于nltk,我曾经遇到类似的问题。请尝试以下安装指南。 Install NLTK

如果您确定它不适用于任何其他模块,您可能在安装不同版本的Python时遇到问题。

还是试一试,看看它说:PIP已安装:

sudo apt-get install python-pip python-dev build-essential 

,看看它是否工作。

16

SSL错误的另一个原因可能是一个糟糕的系统时间 - 证书不会验证它是否离现在太远。

+0

好点,谢谢 – rnix 2014-02-03 13:40:35

+0

同样的问题在这里,非常感谢@pidge – 2018-01-24 11:04:38

1

您还可以使用畅达安装软件包:见http://conda.pydata.org

conda install nltk

使用畅达是下载Miniconda的最好办法,但你也可以试试

pip install conda 
conda init 
conda install nltk 
+3

公平地说,如果'pip install'不起作用,建议通过pip安装另一个软件包管理器......呃,你知道的。 – 2014-09-15 13:46:37

+0

这实际上为我工作。我安装python后安装了anaconda。我不知道anaconda有没有自己的安装程序,直到我读到这个。所以,这是对我有用的答案。特拉维斯的评论解决了鸡/蛋的问题,因为他建议安装miniconda。 – 2016-12-01 23:01:20

0

我解决了这个按照以下步骤发布(在第11sp2页上)

zypper remove pip 
easy_install pip=1.2.1 
pip install --upgrade scons 

以下是傀儡相同的步骤(应在所有发行版工作)

package { 'python-pip': 
    ensure => absent, 
    } 
    exec { 'python-pip': 
    command => '/usr/bin/easy_install pip==1.2.1', 
    require => Package['python-pip'], 
    } 
    package { 'scons': 
    ensure => latest, 
    provider => pip, 
    require => Exec['python-pip'], 
    } 
2

对于我来说,最新的PIP(1.5.6)正常工作与不安全NLTK包,如果你只是告诉它不被如此挑剔的安全性:

pip install --upgrade --force-reinstall --allow-all-external --allow-unverified ntlk nltk 
4

我解决了类似的问题,通过添加--trusted-host pypi.python.org选项

64

我发现因为信任就足够了指定的PyPI主机。例如:

pip install --trusted-host pypi.python.org pytest-xdist 
pip install --trusted-host pypi.python.org --upgrade pip 

这解决了以下错误:

Could not fetch URL https://pypi.python.org/simple/pytest-cov/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) - skipping 
    Could not find a version that satisfies the requirement pytest-cov (from versions:) 
No matching distribution found for pytest-cov 
+2

这对我来说,多年后,在Windows系统上工作 – 2016-08-31 15:46:32

+0

保存我的晚上。 – TMOTTM 2016-11-24 20:41:00

+0

在mac上使用pip3工作给我 – gmogames 2016-12-08 03:05:29

1

如果你通过代理,执行export https_proxy=<your_proxy>(在Unix或Git的bash)的,然后重试安装。

如果您使用的是Windows cmd,则此更改为set https_proxy=<your_proxy>

0

我在Windows 7上执行了以下操作来解决此问题。

C:\ Program Files文件\ Python36 \脚本> PIP安装beautifulsoup4 --trusted主机*

的--trusted主机似乎解决了SSL的问题,*表示每个主机。

当然,这是行不通的,因为你得到了其他的错误,因为没有满足需求的版本beautifulsoup4,但我不认为这个问题与一般问题有关。