Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`pip help install` raise UnicodeDecodeError

Tags:

python

pip

When I tried to use pip to install Cython, I found that an error occurred while compiling. And some basic pip command also gave the same result: UnicodeDecodeError.

The error messages are all like this:

─➤  pip help install
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/usr/local/lib/python2.6/dist-packages/pip/commands/help.py", line 19, in run
    command.parser.print_help()
  File "/usr/lib/python2.6/optparse.py", line 1664, in print_help 
    file.write(self.format_help().encode(encoding, "replace"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 2964: ordinal not in range(128)

I have successfully installed other packages by pip and I don't know why this occurs suddenly. Can anyone tell me how to fix this bug?

Thank you!

Some info: pip 1.0.2 on Ubuntu 10.04

like image 461
mingyc Avatar asked Aug 14 '12 19:08

mingyc


1 Answers

It is not an exact solution, but try to check:

[user@host]$ locale

For me it looks like this:

[w495@w-495-ynb ~]$ locale
LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC=C
LC_TIME=ru_RU.UTF-8
LC_COLLATE=C
LC_MONETARY=C
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER=ru_RU.UTF-8
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT=C
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=

I suppose that problem is in it.

You can try to set locale variables in command line by manualy yourself. For example:

[user@host]$ LANG=en_US.utf8
[user@host]$ pip help install

I'm not sure that exactly LANG helps you. If not — try all from locale output. If it works, set it permanently if you want. Put this

export LANG=en_US.utf8
export <ANY OTHER VAR THAT HELPS>=en_US.utf8

in your ~/.bashrc or ~/.profile and use

[user@host]$ source ~/.bashrc

to apply your changes.

like image 85
Ilia w495 Nikitin Avatar answered Oct 13 '22 11:10

Ilia w495 Nikitin