pip例外:AttributeError:'NoneType'对象没有属性'startswith' [英] pip exception: AttributeError: 'NoneType' object has no attribute 'startswith'

查看:98
本文介绍了pip例外:AttributeError:'NoneType'对象没有属性'startswith'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用pip安装某些软件包时,总是会遇到相同的异常:

When I use pip to install some packages, I always get the same exception:

PS C:\Users\84682\Desktop> pip install django -v
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Collecting django
  1 location(s) to search for versions of django:
  * https://pypi.python.org/simple/django/
  Getting page https://pypi.python.org/simple/django/
  Looking up "https://pypi.python.org/simple/django/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
Cleaning up...
Exception:
Traceback (most recent call last):
  File "d:\python\python3.5\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "d:\python\python3.5\lib\site-packages\pip\commands\install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "d:\python\python3.5\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "d:\python\python3.5\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
    require_hashes
  File "d:\python\python3.5\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "d:\python\python3.5\lib\site-packages\pip\index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "d:\python\python3.5\lib\site-packages\pip\index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "d:\python\python3.5\lib\site-packages\pip\index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "d:\python\python3.5\lib\site-packages\pip\index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "d:\python\python3.5\lib\site-packages\pip\index.py", line 792, in get_page
    "Cache-Control": "max-age=600",
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\sessions.py", line 488, in get
    return self.request('GET', url, **kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 47, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\adapters.py", line 423, in send
    timeout=timeout
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 589, in urlopen
    self._prepare_proxy(conn)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 797, in _prepare_proxy
    conn.connect()
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 254, in connect
    conn = self._new_conn()
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 142, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\connection.py", line 66, in create_connection
    if host.startswith('['):
AttributeError: 'NoneType' object has no attribute 'startswith'
Looking up "https://pypi.python.org/pypi/pip/json" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
There was an error checking the latest version of pip
Traceback (most recent call last):
  File "d:\python\python3.5\lib\site-packages\pip\utils\outdated.py", line 126, in pip_version_check
    headers={"Accept": "application/json"},
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\sessions.py", line 488, in get
    return self.request('GET', url, **kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 47, in send
    resp = super(CacheControlAdapter, self).send(request, **kw)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\adapters.py", line 423, in send
    timeout=timeout
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 589, in urlopen
    self._prepare_proxy(conn)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 797, in _prepare_proxy
    conn.connect()
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 254, in connect
    conn = self._new_conn()
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 142, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "d:\python\python3.5\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\connection.py", line 66, in create_connection
    if host.startswith('['):
AttributeError: 'NoneType' object has no attribute 'startswith'

我发现类似的问题是 python不能在win10中使用? /a>, AttributeError:"NoneType"对象没有属性"startswith" 无法在Python3.6中安装pip .但是他们没有答案.

I found the similar question is python can not be used in win10?, AttributeError: 'NoneType' object has no attribute 'startswith' and Fail to install pip in Python3.6. But they don't have answer.

我正在网上搜索很长时间.但是没用.我不知道.请帮助或尝试给出一些想法来实现这一目标.

I am searching for a long time on net. But no use. I have no idea. Please help or try to give some ideas how to achieve this.

推荐答案

尝试从docker compose运行pip时,我得到了相同的错误消息.导致该错误的根本问题是我用太少的斜杠定义了我的代理设置:http:/myproxy....

I got the same error message trying to run pip from a docker compose. The underlying problem which caused the error was that I had defined my proxy setting with one slash too few: http:/myproxy... .

然后在更正了该错误之后一切正常.

Then after correcting that bug everything worked.

我希望这对遇到相同问题的人有所帮助.

I hope this helps somebody who has the same problem.

这篇关于pip例外:AttributeError:'NoneType'对象没有属性'startswith'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆