0
votes

Before asking this question, I have searched SO, find several related links:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128), regarding reading in files

But they are no useful for my post, all of them are about program, but mine is for installation.

After I install the pip, I check the pip list:

C:\Users\中jin>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.1)
setuptools (28.8.0)

When I install django use pip, I get the bellow error:

C:\Users\中jin>pip install django
Collecting django
Exception:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip\commands\install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "C:\Python27\lib\site-packages\pip\download.py", line 821, in unpack_url
    hashes=hashes
  File "C:\Python27\lib\site-packages\pip\download.py", line 659, in unpack_http_url
    hashes)
  File "C:\Python27\lib\site-packages\pip\download.py", line 880, in _download_http_url
    file_path = os.path.join(temp_dir, filename)
  File "C:\Python27\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position 7: ordinal not in range(128)

EDIT-1

I am in Windows10, and python 2.7.

1

1 Answers

1
votes

I suspect that your temporary directory contains a non-ASCII 7 bit character in the actual path.

If you are on Windows make sure that the environment variable %TEMP% is set to a directory that only uses in it's full path the values in the ranges A-Za-z0-9 no accented characters, symbols, etc.

Note

On windows 10 and python 2.7.13 I have just tested and got:

> pip install django
Collecting django
  Downloading Django-1.11.6-py2.py3-none-any.whl (6.9MB)
    100% |################################| 7.0MB 152kB/s
Requirement already satisfied: pytz in c:\python27\lib\site-packages (from django)
Installing collected packages: django
Successfully installed django-1.11.6
> pip --version
pip 9.0.1 from c:\python27\lib\site-packages (python 2.7)

BUT

> mkdir Témp
> set TEMP=.\Témp
> pip install django
Collecting django
Exception:
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\python27\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "c:\python27\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url
    hashes=hashes
  File "c:\python27\lib\site-packages\pip\download.py", line 659, in unpack_http_url
    hashes)
  File "c:\python27\lib\site-packages\pip\download.py", line 880, in _download_http_url
    file_path = os.path.join(temp_dir, filename)
  File "c:\python27\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 31: ordinal not in range(128)