草棚

Research: DW,NLP,ML,Java Web etc.

安装DBUtils报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in ra

今天在win7上安装DBUtils的时候总是报出如下错误

D:\software\develop_software_installed\DBUtils-1.1\DBUtils-1.1>python setup.py i
nstall
Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    from setuptools import setup
  File "D:\software\develop_software_installed\python27\lib\site-packages\setupt
ools-18.1-py2.7.egg\setuptools\__init__.py", line 11, in <module>
  File "D:\software\develop_software_installed\python27\lib\site-packages\setupt
ools-18.1-py2.7.egg\setuptools\extension.py", line 8, in <module>
  File "D:\software\develop_software_installed\python27\lib\site-packages\setupt
ools-18.1-py2.7.egg\setuptools\dist.py", line 16, in <module>
  File "D:\software\develop_software_installed\python27\lib\site-packages\setupt
ools-18.1-py2.7.egg\setuptools\depends.py", line 6, in <module>
  File "D:\software\develop_software_installed\python27\lib\site-packages\setupt
ools-18.1-py2.7.egg\setuptools\compat.py", line 19, in <module>
  File "D:\software\develop_software_installed\python27\lib\SimpleHTTPServer.py"
, line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "D:\software\develop_software_installed\python27\lib\SimpleHTTPServer.py"
, line 208, in SimpleHTTPRequestHandler
    mimetypes.init() # try to read system mime.types
  File "D:\software\develop_software_installed\python27\lib\mimetypes.py", line
358, in init
    db.read_windows_registry()
  File "D:\software\develop_software_installed\python27\lib\mimetypes.py", line
258, in read_windows_registry
    for subkeyname in enum_types(hkcr):
  File "D:\software\develop_software_installed\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)


解决方法:

在DBUtils下的setup.py文件添加如下三行代码

import sys
reload(sys) 
sys.setdefaultencoding('gb18030')

重新运行python setup.py install就能成功安装DBUtils了。



阅读更多
版权声明: https://blog.csdn.net/cao812755156/article/details/52370166
文章标签: python
个人分类: Python
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

安装DBUtils报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in ra

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭