json.load/simplejson.load在打包的Python应用程序(PyInstaller或cx_freeze)中失败

json.load/simplejson.load在打包的Python应用程序(PyInstaller或cx_freeze)中失败,python,json,windows,pyinstaller,cx-freeze,Python,Json,Windows,Pyinstaller,Cx Freeze,我有一个命令行Python应用程序,它加载命令行上指定的JSON文件: with open(sys.argv[1]) as f: data = json.load(f) 在使用系统Python解释器运行应用程序时,这一切都很好,但一旦通过PyInstaller或cx_freeze将其打包成EXE,我就会出现以下错误: Traceback (most recent call last): File "<string>", line 92, in <module>

我有一个命令行Python应用程序,它加载命令行上指定的JSON文件:

with open(sys.argv[1]) as f:
    data = json.load(f)
在使用系统Python解释器运行应用程序时,这一切都很好,但一旦通过PyInstaller或cx_freeze将其打包成EXE,我就会出现以下错误:

Traceback (most recent call last):
  File "<string>", line 92, in <module>
  File "c:\Users\user\Documents\build\main\out00-PYZ.pyz\simplejson"
, line 444, in load
  File "c:\Users\user\Documents\build\main\out00-PYZ.pyz\simplejson"
, line 501, in loads
  File "c:\Users\user\Documents\build\main\out00-PYZ.pyz\simplejson.
decoder", line 370, in decode
  File "c:\Users\user\Documents\build\main\out00-PYZ.pyz\simplejson.
decoder", line 389, in raw_decode
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
已知所讨论的JSON文件是有效的,并且可以从REPL加载而不会出现问题

有没有人想过问题可能是什么

更新1:奇怪的是,当我用硬编码的文件名替换sys.argv[1]时,一切正常。我已确认sys.argv[1]正确映射到冻结应用程序中的文件名

更新2:我已经确认,在json.load调用成功后会引发异常-在可以访问该异常后立即插入print语句


更新3:假警报!此应用程序使用Flask,结果发现我启用了调试模式,这导致自动阅读器尝试使用不正确的参数再次运行main()块。

假警报!这个应用程序使用Flask,结果发现我启用了调试模式,这导致自动阅读器尝试使用不正确的参数再次运行main()块


如果您将任何类型的打包机与FLask应用程序一起使用,请确保禁用调试模式。

可以在SO上发布您自己问题的答案,并将其标记为已接受-这有助于其他用户知道您的问题已得到解决,而无需加载问题:)
ValueError: No JSON object could be decoded