saltstack--关于报错“UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 6: ordinal not in range(128)”

[[email protected] 桌面]# salt-key
[ERROR ] ‘ascii‘ codec can‘t decode byte 0xe6 in position 6: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/parsers.py", line 210, in parse_args
process_option_func()
File "/usr/lib/python2.7/site-packages/salt/utils/parsers.py", line 386, in process_saltfile
saltfile = os.path.join(os.getcwd(), ‘Saltfile‘)
File "/usr/lib64/python2.7/posixpath.py", line 80, in join
path += ‘/‘ + b
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe6 in position 6: ordinal not in range(128)
Usage: salt-key [options]

salt-key: error: Error while processing <bound method SaltKey.process_saltfile of <salt.cli.key.SaltKey object at 0x7f4734a5ae50>>: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/utils/parsers.py", line 210, in parse_args
process_option_func()
File "/usr/lib/python2.7/site-packages/salt/utils/parsers.py", line 386, in process_saltfile
saltfile = os.path.join(os.getcwd(), ‘Saltfile‘)
File "/usr/lib64/python2.7/posixpath.py", line 80, in join
path += ‘/‘ + b
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe6 in position 6: ordinal not in range(128)

SaltStack管理工具允许管理员对多个操作系统创建一个一致的管理系统,包括VMware vSphere环境。

在安装saltstack的过程中,执行到 salt-key(在master中查看所有key的状态)的时候,遇到上述报错。

  1. 在python的安装路径下找到     \Lib\mimetypes.py文件

  2. 在导包下面加入以下代码,将编码格式改成gbk

    

if sys.getdefaultencoding() != ‘gbk‘:
    reload(sys)
    sys.setdefaultencoding(‘gbk‘)

就是这样

saltstack--关于报错“UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 6: ordinal not in range(128)”

原文地址:https://www.cnblogs.com/lutt/p/11253487.html

时间: 2024-10-16 01:13:30

saltstack--关于报错“UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 6: ordinal not in range(128)”的相关文章

运行python代码报错UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe7 in position 91: ordinal not in range(128)的解决办法

1.通过搜集网上的资料,自己多次尝试,问题算是解决了,在代码中加上如下几句即可: import sys reload(sys) sys.setdefaultencoding('utf-8') 2.原因就是Python的str默认是ascii编码,和unicode编码冲突,混淆了python2 里边的 str 和 unicode 数据类型. 3.python3 区分了 unicode str 和 byte arrary,并且默认编码不再是 ascii. 运行python代码报错UnicodeDec

安装mysql-python报错:UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe2 in position 65: ordinal not in range(128)

安装mysql-python报错: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 65: ordinal not in range(128) 需要先安装(yum): mysql-develpython-devel 安装mysql-python报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 65: ordinal

python2 使用openpyxl 报错UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xd7 in position 20: ordinal not in range(128) 解决方法

# -*- coding: utf-8 -*- #! /usr/bin/env python # author: xiao~~ import openpyxl import sys reload(sys) sys.setdefaultencoding('utf-8') wb2=openpyxl.Workbook() wb2.save('test1.xlsx') print('新建成功') 附上剪短的代码 报错信息 Traceback (most recent call last): File "

Python报错“UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe9 in position 0: ordinal not in range(128)”的解决办法

最近在用Python处理中文字符串时,报出了如下错误: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)   1.原因 因为默认情况下,Python采用的是ascii编码方式,如下所示: ?? python -c "import sys; print sys.getdefaultencoding()" ascii ?? 而Python在进行编

python安装程序是报这样的错UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xb0 in position 1: ordinal not in range(128)

python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128) 有2种方法设置python的默认编码: 方法一: 在程序中加入以下代码: import sys reload(sys) sys.setdefaultencoding('utf8') 方法二:

UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe6 in position 9: ordinal not in range(128)

系统:Ubuntu 15.04 Spyder版本:spyder 2.3.2+dfsg-1ubuntu1 运行python程序出现错误UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 9: ordinal not in range(128) 如下图所示: 解决方法: 在程序开头加上这三行: sys () .() UnicodeDecodeError: 'ascii' codec can't decode byt

解决UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe5 in position 0: ordinal not in range(128)

kilo版,horizon界面用中文,删除时报错."UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)" 出错原因就是python的str默认是ascii编码,和unicode编码冲突,就会报这个标题错误.那么该怎样解决呢? 解决方法如下: vim /usr/lib/python2.7/site-packages/horizon/tables/

python2 UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xce in position 7: ordinal not in range(128)

python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128),python没办法处理非ascii编码的,此时需要自己设置将python的默认编码,一般设置为utf8的编码格式. 查询系统默认编码可以在解释器中输入以下命令:python代码 >>>

[Python] 运行Flask, 报错:UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xc4 in position 33: ordinal not in range(128)

运行时报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 33: ordinal not in range(128) Python2.7在Windows上一个bug!!! 解决方法: 参考官方patch: http://bugs.python.org/file19332/9291a.patch 如下代码:一,加入from itertools import count: 二,修改 def enum_type