Python error UnicodeDecodeError: ascii codec can t decode byte 0xe0... solution

Source: Internet
Author: User

After installing Python2.7 on a Windows 8 machine, it is always the error unicodedecodeerror to download some package packages for Setup, as follows:

File "c:/python27/lib/mimetypes.py", line (in Enum_types)

CType = Ctype.encode (default_encoding) # Omit in 3.x!

Unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xe0 in position 0:ordinal not in range (128)

The following solutions are available for online search:

1. This is the Python 2 mimetypes bug.

2. You need to comment or delete the following fragment in the python2.7/lib/mimetypes.py file:

Try
CType = Ctype.encode (default_encoding) # Omit in 3.x!
Except Unicodeencodeerror:
Pass

Complement other solutions

Solution:

Add code to the error page: Import sys
Reload (SYS)
Sys.setdefaultencoding (' UTF8 ')

Execute Python ez_setup.py, error:

Unicodedecodeerror: ' UTF8 ' codec can ' t decode byte 0xb0 in position 35:invalid
Start byte

Solution:

Add code to the error page: Import sys
Reload (SYS)
Sys.setdefaultencoding (' GB18030 ')

Then execute the Python ez_setup.py and succeed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.