Python 安装setuptools报‘ascii’错误

方法/步骤
  1. 首先你电脑确保已经安装了Python,并且在系统的环境变量里面的Path加入了Python的安装地址,最后的结果就是能在“开始”-》“cmd”-->"Python"回车的时候能正常显示Python的版本信息。然后已经从网上下载了ez_setup.py文件(下载进入https://pypi.python.org/pypi/setuptools/)

  2. 然后在cmd进入命令行窗口, 进入ez_setup.py目录,我这里是下载放置在F盘,然后输入命令:python ez_setup.py 系统就会自动下载setuptools工具安装,最后的结局是显示编码错误:

    F:\>python ez_setup.py

    Extracting in c:\users\yc_00001\appdata\local\temp\tmpujxuqp

    Now working in c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0

    Installing Setuptools

    Traceback (most recent call last):

      File "setup.py", line 19, in <module>

        exec(init_file.read(), command_ns)

      File "<string>", line 11, in <module>

      File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools

    \__init__.py", line 12, in <module>

        from setuptools.extension import Extension

      File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools

    \extension.py", line 8, in <module>

        from .dist import _get_unpatched

      File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools

    \dist.py", line 16, in <module>

        from setuptools.depends import Require

      File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools

    \depends.py", line 6, in <module>

        from setuptools import compat

      File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools

    \compat.py", line 19, in <module>

        from SimpleHTTPServer import SimpleHTTPRequestHandler

      File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>

        class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):

      File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHand

    ler

        mimetypes.init() # try to read system mime.types

      File "C:\Python27\lib\mimetypes.py", line 358, in init

        db.read_windows_registry()

      File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry

        for subkeyname in enum_types(hkcr):

      File "C:\Python27\lib\mimetypes.py", line 249, in enum_types

        ctype = ctype.encode(default_encoding) # omit in 3.x!

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal

    not in range(128)

    Something went wrong during the installation.

    See the error message above.

  3. 3

    解决方案,在网上找了很多方法,下面这个可用(忘了出处了,请原作者原谅....):

    打开C:\Python27\Lib 找到mimetypes.py 在大概256行处找到default_encoding = sys.getdefaultencoding()

    在这行前加上:

    if sys.getdefaultencoding()!='gbk':

       reload(sys)

       sys.setdefaultencoding('gbk')

    然后保存,再运行python ez_setup.py即可,下面是我自己的截图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值