【问题标题】:Python library installation problem (through pip install)Python库安装问题(通过pip install)
【发布时间】:2020-03-17 19:21:32
【问题描述】:

我的 MacBook Pro 中安装了 Python 3.6.5 和 anaconda 5.2.0。如果我尝试通过pip install 安装任何库,我会收到以下错误消息。你能告诉我为什么吗?在下文中,我提供了pip install spacy 的示例。

$ pip install spacy
Collecting spacy
Exception:
Traceback (most recent call last):
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 318, in run
    resolver.resolve(requirement_set)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/resolve.py", line 102, in resolve
    self._resolve_one(requirement_set, req)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/resolve.py", line 256, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/resolve.py", line 209, in _get_abstract_dist_for
    self.require_hashes
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 218, in prepare_linked_requirement
    req.populate_link(finder, upgrade_allowed, require_hashes)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 164, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/index.py", line 572, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/index.py", line 534, in find_all_candidates
    self._package_versions(page.iter_links(), search)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/index.py", line 701, in _package_versions
    for link in self._sort_links(links):
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/index.py", line 690, in _sort_links
    for link in links:
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_internal/index.py", line 880, in iter_links
    namespaceHTMLElements=False,
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/html5parser.py", line 47, in parse
    return p.parse(doc, **kwargs)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/html5parser.py", line 289, in parse
    self._parse(stream, False, None, *args, **kwargs)
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/html5parser.py", line 134, in _parse
    self.mainLoop()
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/html5parser.py", line 205, in mainLoop
    for token in self.normalizedTokens():
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/html5parser.py", line 264, in normalizedTokens
    for token in self.tokenizer:
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/_tokenizer.py", line 59, in __iter__
    while self.state():
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/_tokenizer.py", line 243, in dataState
    data = self.stream.char()
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/_inputstream.py", line 246, in char
    if not self.readChunk():
  File "/Users/sh0/anaconda3/lib/python3.6/site-packages/pip/_vendor/html5lib/_inputstream.py", line 265, in readChunk
    data = self.dataStream.read(chunkSize)
  File "/Users/sh0/anaconda3/lib/python3.6/codecs.py", line 499, in read
    data = self.bytebuffer + bytes(newdata,encoding='utf8')
TypeError: encoding without a string argument  

【问题讨论】:

  • 你有 64 位的 Python 吗?
  • 是的,它是 64 位。
  • 如果您使用的是 Conda,为什么要通过 pip 安装库?您是否在环境中运行 pip 安装?

标签: python python-3.x python-2.7 anaconda spacy


【解决方案1】:

我将首先运行pip list --outdated,它会显示哪些模块已过期,但这样做会给你正确的方法来更新 pip 如果它没有数据,你应该这样做python -m pip install pip --upgrade

另外,您可以尝试启用最大详细度的安装命令吗? (pip install -vvv ...)。

祝你好运,希望这会有所帮助。

【讨论】:

  • 谢谢。我试过python -m pip install pip --upgrade。它给了我在问题中提到的相同错误消息。
猜你喜欢
  • 2017-12-22
  • 1970-01-01
  • 2022-06-30
  • 2022-06-13
  • 1970-01-01
  • 2018-06-04
  • 2016-10-14
  • 2020-10-03
  • 2021-03-21
相关资源
最近更新 更多