question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-ascii error with pip install

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
Andrej730commented, Jun 13, 2015

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') 
1reaction
mitsuhikocommented, Jan 16, 2016

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)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip install Unicode error when having non-ASCII ...
Pip install Unicode error when having non-ASCII characters in your User folder name on Windows ... Basically pip install can not install some ......
Read more >
Error with non-ASCII character?
Using 3.9.0 under Windows 10. I get an error with "pip install pyinstaller" as below (my username REDACTED in this excerpt):
Read more >
python 3 pip install non-ASCII payload error
Using python3.4 w/ pip trying to install django-floppyforms==1.1 and got this non-ASCII payload error . I don't get this error with python2.7 ....
Read more >
Unidecode
Unidecode 1.3.6 · Module content. This library contains a function that takes a string object, possibly containing non-ASCII characters, and returns a string ......
Read more >
Removal of Non ASCII characters using Python
What are non ascii characters ? You might have faced an issue while copy pasting text from document ( docx ) to HTML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found