"az"万一出现".azure/az.sess"命令,命令将因无用的错误而崩溃.是空的 [英] "az" command crashes with unhelpful error in case ".azure/az.sess" is empty

查看:214
本文介绍了"az"万一出现".azure/az.sess"命令,命令将因无用的错误而崩溃.是空的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从https://docs.microsoft.com/zh-cn/cli/azure/install-azure-cli?view=蔚蓝气候最新版本

I just did a new install of the Azure CLI 2.0 tools on my Win10 laptop from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest

最终的结果是,每当我尝试运行任何az -command时,它都会因非常无用的JSONDecodeError -exception跟踪而崩溃.

What ended up happening was every time I tried to run any az -command it would crash with a very unhelpful JSONDecodeError -exception trace.

最终,我最终手动安装了python azure-cli软件包并尝试以这种方式运行它,得到了更多有用的回溯,该回溯告诉了我要在驱动器中找到的文件名(az.sess). %USERPROFILE%\.azure-目录, 作为一个空文件.

Eventually I ended up installing the python azure-cli package manually and trying to run it like that, got a bit more helpful backtrace that told me the filename it was looking for (az.sess) which I found on my drive in the %USERPROFILE%\.azure -directory, as an empty file.

删除目录使az命令再次起作用.

Deleting the directory made the az command work again.

请为az.sess等文件中的错误添加适当的处理方式.

Please add proper handling for errors in your az.sess etc. files.

C:\Users\lietu>az
Traceback (most recent call last):
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\azure\cli\__main__.py", line 32, in <module>
    az_cli = get_default_cli()
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\azure\cli\core\__init__.py", line 509, in get_default_cli
    help_cls=AzCliHelp)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\azure\cli\core\__init__.py", line 54, in __init__
    SESSION.load(os.path.join(azure_folder, 'az.sess'), max_age=3600)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\azure\cli\core\_session.py", line 40, in load
    self.data = json.load(f)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\lietu\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


推荐答案

Removing the temporary folder (C:\Users\Name\.azure) for Azure CLI, will resolve the issue.

此时可能存在无效数据(格式错误),您可能会收到此错误或损坏的JSON文档)或由于数据被截断了.

在大多数情况下,您的JSON加载JSONDecodeError:期望值:line 1 column 1 (char 0)错误是由于:

  • 非JSON引用
  • XML/HTML输出(即,以<开头的字符串)
  • 不兼容的字符编码

--------------- -------------------------------------------------- ------------------------------

如果此答案有帮助,请单击标记为答案"或向上" -投票".要提供有关您的论坛体验的其他反馈,请单击 这里 /p>

If this answer was helpful, click "Mark as Answer" or "Up-Vote". To provide additional feedback on your forum experience, click here


这篇关于"az"万一出现".azure/az.sess"命令,命令将因无用的错误而崩溃.是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆