pip: Non-ascii error with pip install

Trying to use pip install but keep getting this message. Think it may have to do with the ‘í’ in my name (Oisín) as that is in my path name.

PS C:\Users\Oisín\audiogrep> pip install -r requirements.txt
Collecting pydub==0.9.5 (from -r requirements.txt (line 1))
 Exception:
 Traceback (most recent call last):
   File "C:\Python27\lib\site-packages\pip\basecommand.py", line 232, in main
     status = self.run(options, args)
   File "C:\Python27\lib\site-packages\pip\commands\install.py", line 339, in run
     requirement_set.prepare_files(finder)
   File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 333, in prepare_files
     upgrade=self.upgrade,
   File "C:\Python27\lib\site-packages\pip\index.py", line 305, in find_requirement
     page = self._get_page(main_index_url, req)
   File "C:\Python27\lib\site-packages\pip\index.py", line 783, in _get_page
     return HTMLPage.get_page(link, req, session=self.session)
   File "C:\Python27\lib\site-packages\pip\index.py", line 872, in get_page
     "Cache-Control": "max-age=600",
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 473, in get
     return self.request('GET', url, **kwargs)
   File "C:\Python27\lib\site-packages\pip\download.py", line 365, in request
     return super(PipSession, self).request(method, url, *args, **kwargs)
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 461, in request
     resp = self.send(prep, **send_kwargs)
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 610, in send
     r.content
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\models.py", line 730, in content
     self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\models.py", line 655, in generate
     for chunk in self.raw.stream(chunk_size, decode_content=True):
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 256
     data = self.read(amt=amt, decode_content=decode_content)
   File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 186
     data = self._fp.read(amt)
   File "C:\Python27\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 54, in read
     self.__callback(self.__buf.getvalue())
   File "C:\Python27\lib\site-packages\pip\_vendor\cachecontrol\controller.py", line 217, in cache_
     self.serializer.dumps(request, response, body=body),
   File "C:\Python27\lib\site-packages\pip\download.py", line 268, in set
     return super(SafeFileCache, self).set(*args, **kwargs)
   File "C:\Python27\lib\site-packages\pip\_vendor\cachecontrol\caches\file_cache.py", line 83, in
     with FileLock(name) as lock:
   File "C:\Python27\lib\site-packages\pip\_vendor\lockfile\mkdirlockfile.py", line 18, in __init__
     LockBase.__init__(self, path, threaded, timeout)
   File "C:\Python27\lib\site-packages\pip\_vendor\lockfile\__init__.py", line 189, in __init__
     hash(self.path)))
   File "C:\Python27\lib\ntpath.py", line 84, in join
     result_path = result_path + p_path
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position 3: ordinal not in range(128)''''

Using pip 6.0.8 on Windows with Python 2.7

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 25 (13 by maintainers)

Most upvoted comments

I figure out what was wrong in my case - my full computer name was “ПК” which is “PC” in russian and whenever join function trying to result_path = result_path + p_path Python 2 implicitly trying to decode bytes from p_path to unicode as ascii and cause thats not possible i’ve got this decoding error. So, my solution - add decoding as latin1 in LockBase’s init (in C:\Python27\Lib\site-packages\pip-7.0.3-py2.7.egg\pip_vendor\lockfile_init_.py): this

self.hostname = socket.gethostname()

to this

self.hostname = socket.gethostname().decode('latin1') 

This was just reported by a user of lektor as something that is still happening on Russian windows PCs:

  File "c:\temp\site\venv\lib\site-packages\pip\_vendor\lockfile\__init__.py", line 189, in __init__
    hash(self.path)))
  File "c:\temp\site\venv\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)