Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while installing pip using get-pip.py with Python2.7.10

I am using Python2.7.10 on a Windows10 machine, and wish to install pip.

I followed the instructions from here to get the get-pip.py file, but when I try to run it I get the following error:

Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence

I found that if I install an older version of pip (for Python2.6) then the installation is successful, and I can use pip regularly. If I try to use this older version (9.0.3) to install the newer one (18.0) then I get the same error message.

The complete log of the installation is below (1). If I manually install setuptools then I get the same message when it tries to download the next package:

Any assistance with installing the newer version will be much appreciated :-)

1)

C:\Python27\Lib\site-packages>python get-pip.py
Collecting pip
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/ff/f4/385715ccc461885f3cedf57a41ae3c12b5fec3f35cce4c8706b1a112a133/setuptools-40.0.0-py2.py3-none-any.whl (567kB)
    1% |Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence

Update: after installing several packages manually I was able to install the new pip version. It obviously didn't solve the problem, and pip is still not working. When trying to use it, the same error message appears at every attempted download. See log at (2). I double checked the address, and it appears to be correct.

2)

Collecting Requests
  Downloading https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB)
    11% |Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence

Thanks

like image 790
N.C Avatar asked Feb 17 '26 19:02

N.C


1 Answers

tl;qr - add the quiet flag (-q) to your command

While trying to debug I redirected the output to a file:

python -m pip install requests > .\temp.txt

Surprisingly, everything suddenly worked!

It appears there is a known bug (Thanks Matan M) while displaying the progress bar to the console. Basically, any solution that would avoid writing it would work.

Here are some options:

  1. Use the -q flag
  2. Turn off the progress bar using --progress-bar off
  3. Redirect to a temp file

:-)

like image 182
N.C Avatar answered Feb 20 '26 07:02

N.C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!