无法在Windows上升级pip

时间:2015-09-12 20:09:44

标签: python windows pip upgrade

我是python和包管理系统pip的新手。我在Windows 7上安装了python 2.7.10并检查了它包含的pip版本--pip 7.0.1。我决定升级pip并输入

python -m pip install -U pip

但我有这个错误

Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\basecommand.py", l
ine 223, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\commands\install.p
y", line 280, in run
    requirement_set.prepare_files(finder)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\req\req_set.py", l
ine 317, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\req\req_set.py", l
ine 304, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\req\req_set.py", l
ine 387, in _prepare_file
    req_to_install, finder)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\req\req_set.py", l
ine 348, in _check_skip_installed
    finder.find_requirement(req_to_install, self.upgrade)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\index.py", line 48
6, in find_requirement
    all_versions = self._find_all_versions(req.name)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\index.py", line 40
4, in _find_all_versions
    index_locations = self._get_index_urls_locations(project_name)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\index.py", line 37
8, in _get_index_urls_locations
    page = self._get_page(main_index_url)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\index.py", line 81
0, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\index.py", line 92
0, in get_page
    "Cache-Control": "max-age=600",
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\s
essions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\download.py", line
 373, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\s
essions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\s
essions.py", line 605, in send
    r.content
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\m
odels.py", line 750, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes
()
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\m
odels.py", line 673, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\p
ackages\urllib3\response.py", line 307, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\requests\p
ackages\urllib3\response.py", line 243, in read
    data = self._fp.read(amt)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\cachecontr
ol\filewrapper.py", line 54, in read
    self.__callback(self.__buf.getvalue())
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\cachecontr
ol\controller.py", line 244, in cache_response
    self.serializer.dumps(request, response, body=body),
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\download.py", line
 276, in set
    return super(SafeFileCache, self).set(*args, **kwargs)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\cachecontr
ol\caches\file_cache.py", line 99, in set
    with self.lock_class(name) as lock:
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\lockfile\m
kdirlockfile.py", line 18, in __init__
    LockBase.__init__(self, path, threaded, timeout)
  File "C:\Program Files (x86)\Python27\lib\site-packages\pip\_vendor\lockfile\_
_init__.py", line 189, in __init__
    hash(self.path)))
  File "C:\Program Files (x86)\Python27\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 10: ordinal
 not in range(128)

我试图进入

pip install --upgrade pip

但我得到了相同的结果。

1 个答案:

答案 0 :(得分:0)

你的windows用户名是否包含非ascii字符?

如果是这样,你需要从exe安装pip,或者更改用户