首页 > 其他分享 >pytest运行报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in position 82: illegal multibyte

pytest运行报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in position 82: illegal multibyte

时间:2024-06-03 16:35:24浏览次数:26  
标签:Python illegal py environment 报错 0xaf line config python3.9

pytest运行报错:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xaf in position 82: illegal multibyte sequence

 

 

D:\Python\environment\python3.9.7\python3.exe D:/Python/nas_autotest/run.py
Traceback (most recent call last):
  File "D:\Python\nas_autotest\run.py", line 15, in <module>
    pytest.main(["--junitxml=reports/results.xml"])  # 用例生成执行统计结果
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\__init__.py", line 318, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "D:\Python\environment\python3.9.7\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "D:\Python\environment\python3.9.7\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "D:\Python\environment\python3.9.7\lib\site-packages\pluggy\_callers.py", line 55, in _multicall
    gen.send(outcome)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\helpconfig.py", line 100, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "D:\Python\environment\python3.9.7\lib\site-packages\pluggy\_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "D:\Python\environment\python3.9.7\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\__init__.py", line 1283, in parse
    self._preparse(args, addopts=addopts)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\__init__.py", line 1157, in _preparse
    self._initini(args)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\__init__.py", line 1076, in _initini
    rootpath, inipath, inicfg = determine_setup(
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\findpaths.py", line 184, in determine_setup
    rootdir, inipath, inicfg = locate_config([ancestor])
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\findpaths.py", line 106, in locate_config
    ini_config = load_config_dict_from_file(p)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\findpaths.py", line 45, in load_config_dict_from_file
    iniconfig = _parse_ini_config(filepath)
  File "D:\Python\environment\python3.9.7\lib\site-packages\_pytest\config\findpaths.py", line 30, in _parse_ini_config
    return iniconfig.IniConfig(str(path))
  File "D:\Python\environment\python3.9.7\lib\site-packages\iniconfig\__init__.py", line 54, in __init__
    tokens = self._parse(iter(f))
  File "D:\Python\environment\python3.9.7\lib\site-packages\iniconfig\__init__.py", line 82, in _parse
    for lineno, line in enumerate(line_iter):
UnicodeDecodeError: 'gbk' codec can't decode byte 0x8d in position 590: illegal multibyte sequence

Process finished with exit code 1

解决方式:
第一种:
将pytest.ini文件中的中文字符串去掉

如果需要保留中文备注,则使用第二种方法:
点击报错内容倒数第二个

 

f = open(self.path,encoding='utf-8')

 

标签:Python,illegal,py,environment,报错,0xaf,line,config,python3.9
From: https://www.cnblogs.com/chenxiaomeng/p/18229152

相关文章

  • std::numeric_limits::max和宏定义重复报错问题
    std::numeric_limits::max和宏定义重复报错问题问题描述今天在编译BeckhoffADS开源组件的时候发现编译报错,报错代码如下longAdsDevice::ReadReqEx2(uint32_tgroup,uint32_toffset,size_tlength,void*buffer,uint32_t*bytesRead)const{if(length>std::nume......
  • CMakeFile.txt通过sysroot方式后生成makefile报错
    怪不得博客园干不过别家,体验真的不太好。通过openwrite发布文章,其他平台都能发布,就博客园限制了,理由是文字少的文章限制发布到该平台。哎,这种行为当真是扶不起的阿斗。以后也不要太把博客园当回事了,迟早要关门的报错信息如下:--TheCcompileridentificationisunknown--T......
  • git 命令报错:Another git process seems to be running in this repository, e.g. an
    执行git命令时,报错:Anothergitprocessseemstoberunninginthisrepository,e.g.aneditoropenedby'gitcommit'.Pleasemakesureallprocessesareterminatedthentryagain.Ifitstillfails,agitprocessmayhavecrashedinthisrepository......
  • 联想打印机更换硒鼓后仍旧报错,如何做硒鼓计数器清零?
        在联想打印机的使用过程中,硒鼓是一个重要的耗材,它直接影响到打印质量和打印机的运行。通常,当打印机显示硒鼓错误或者打印质量下降时,更换新的硒鼓是一个常见的解决方案。然而,有时候即使更换了新的硒鼓,打印机仍然会报错,这可能是由于硒鼓计数器没有清零导致的。  ......
  • svg图片放img标签报错解决办法
    错误代码:<divv-if="item.showType=='2'":id="'tag'+index"class="tag-icon-text"@click="tagClick(item)"><imgsrc="@/assets/images/flag.jpg"class="img"/>......
  • 解决安装cuda时vs报错MSB3721的问题
    以下几种可能1.调整调试平台为x642.点击vs顶部导航栏的调试->最下面那一项属性->CUDAC/C++->Common->CUDADustuomDir设置为你安装CUDAtoolkit的目录3.如果你的电脑系统用户名为中文,请前往环境变量->用户变量,将tmp和temp的值修改为一个新文件夹(建议在D盘里面创建一个tem......
  • vscode 报错:应输入表达式
    如图,报错:应输入表达式,但是我的==看起来是正确的。后面发现原来是我的定义有问题,这里定义处多了分号“;”,然后vscode检测不到该定义,故会报错。......
  • springboot本地运行正常,打包jar包上传Linux服务器后报错,无法正常运行解决方法
    问题描述:springboot本地运行正常,打包jar包上传Linux服务器后报错,无法正常运行说明:以下两种打包方式均在IDEA软件内完成,上传服务器使用宝塔面板管理1.第一次打包方式; 设置完打包路径后,进入build菜单进行打包:  选择build或rebuild进行打包,打包后上传jar包到服务器,运......
  • [ROS报错问题]SystemError: initialization of cv_bridge_boost raised unreported ex
            在运行ROS代码时,很多人会使用到cv_bridge库,这个库的主要功能是帮助在ROS的图像消息(sensor_msgs/Image)和OpenCV的图像格式(cv::Mat)之间进行转换。然而,有时在使用cv_bridge时会遇到一个让人头疼的问题,即报错:fromcv_bridge.boost.cv_bridge_boostimportcvt......
  • matlab 2024a 在只有核显的机器上opengl报错的问题 X11GLXDrawableFactory
    com.jogamp.opengl.GLException:X11GLXDrawableFactory-CouldnotinitializesharedresourcesforX11GraphicsDevice[type.x11,connection:0,unitID0,handle0x0,ownerfalse,ResourceToolkitLock[obj0x37e10dfd,isOwnerfalse,<4dd74231,25b2e611>[c......