0

当我尝试从我的 anaconda 环境中安装软件包时,我收到“ValueError:Invalid IPv6 URL”错误消息(下面的完整错误)。具体来说,错误似乎在urlsplit.

我在代理后面,因此我尝试在 .pip/pip.conf 中明确设置代理详细信息并将其明确附加到命令行。两种情况下的误差略有不同。请注意,在我的密码中,我没有这些特殊符号@、$、-、#。我确实有一些特殊字符,因为它们是系统需要的。我试图将它们放入引号,双引号,反斜杠......什么都没有。

$ cat .pip/pip.conf
[global]
timeout = 60
index-url = https://pypi.python.org/simple/
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org
proxy = http://username:password@ipadress:port

[install]
index-url = https://pypi.python.org/simple/

原来的 commnadnd + 错误信息在这里:

$ pip3 install Cython
Collecting Cython
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 328, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 748, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
    finder, self.upgrade, require_hashes)
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 442, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 400, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 545, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 648, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 757, in get_page
    "Cache-Control": "max-age=600",
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 492, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/pip/download.py", line 378, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 588, in send
    r = adapter.send(request, **kwargs)
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 343, in send
    conn = self.get_connection(request.url, proxies)
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 253, in get_connection
    proxy = prepend_scheme_if_needed(proxy, 'http')
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/utils.py", line 666, in prepend_scheme_if_needed
    scheme, netloc, path, params, query, fragment = urlparse(url, new_scheme)
  File "/usr/lib/python3.5/urllib/parse.py", line 295, in urlparse
    splitresult = urlsplit(url, scheme, allow_fragments)
  File "/usr/lib/python3.5/urllib/parse.py", line 363, in urlsplit
    raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL

通过将代理附加到命令行,我得到一条稍微短一点的消息:

$ pip install Cython --proxy = https://username:password@ipadress:port
ERROR: Exception:
Traceback (most recent call last):
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 305, in run
    reqs = self.get_requirements(args, options, finder, session)
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 385, in get_requirements
    user_supplied=True,
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/req/constructors.py", line 366, in install_req_from_line
    parts = parse_req_from_line(name, line_source)
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/req/constructors.py", line 281, in parse_req_from_line
    link = Link(name)
  File "/home/mdi0316/anaconda3/lib/python3.6/site-packages/pip/_internal/models/link.py", line 73, in __init__
    self._parsed_url = urllib.parse.urlsplit(url)
  File "/home/mdi0316/anaconda3/lib/python3.6/urllib/parse.py", line 460, in urlsplit
    raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL

我还能尝试什么?

谢谢你。

PS,为什么我使用 pip3 而不是 pip?出于某种原因,我的默认 pip 是 anaconda 的,因此我也可以 anaconda3/pip 安装它,但是 /usr/bin/python 将无法识别它。

$which python
> /usr/bin/python
$ python --version
> Python 3.5.2

$ which pip
> /usr/bin/pip
$ pip --version
> pip 21.3.1 from /home/userid/anaconda3/lib/python3.6/site-packages/pip (python 3.6)

$ which python3
> /usr/bin/python3
$ python3 --version
> Python 3.5.2

$ which pip3
> /usr/bin/pip3
$ pip3 --version
> pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)

然后我尝试了sudo apt-get remove python-pipsudo apt install python-pip但我得到了相同的 anaconda3 版本:

$ which pip
> /usr/bin/pip
$ pip --version
> pip 21.3.1 from /home/userid/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
4

1 回答 1

0

我从密码中删除了所有符号,只保留了字母数字,它现在可以工作了。

于 2022-02-07T08:49:02.060 回答