Python Install third-party module Unicodedecodeerror: ' ASCII ' codec can ' t decode byte

Source: Internet
Author: User

Python to install a third-party module, you can use the Easy_install ' module name ' to install the module directly, but I encountered an error when installing Easy_install unicodedecodeerror: ' ASCII ' codec can ' t Decode byte

Download Ez_setup.py:https://pypi.python.org/pypi/setuptools#windows to a directory first

CMD->CD to the downloaded directory

<span style= "FONT-SIZE:18PX;" >python ez_setup.py</span>

This time if there is no error, Easy_install installed, you can see C:\Python27\ a script this directory, below the Easy_install.exe, so the next step is to add this directory to the system variable path


After that, you can run Easy_install directly on the command line, but in this place, there will be title errors, for reasons related to the registry, and possibly the GBK format that some native software may overwrite the registry, resulting in Python's inability to install third-party libraries.

Workaround: Open the mimetypes.py file under C:\Python27\Lib and find about 256 lines (you can use the notepad++ search function)

' default_encoding = sys.getdefaultencoding () '.

Add three lines in front of this line: (note indent)

<span style= "FONT-SIZE:18PX;" >if sys.getdefaultencoding ()! = ' GBK ':      reload (SYS)      sys.setdefaultencoding (' GBK ')  default_encoding = Sys.getdefaultencoding () </span>

Save, run again, for example, we want to install an image processing module, this module is called PiL

<span style= "FONT-SIZE:18PX;" >easy_install pil</span>

OK, error resolved.

Python Install third-party module Unicodedecodeerror: ' ASCII ' codec can ' t decode byte

Related Article

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.