使用 Pynsist 时出现 KeyError

KeyError when using Pynsist

我正在尝试复制以下示例:https://github.com/takluyver/pynsist/tree/master/examples/tkinter 但它不起作用。我有一个从这里复制粘贴的 python 文件和 .cfg,但是当我在命令提示符下 运行 py -m nsist installer.cfg 时,出现以下错误:

C:\Users\Mike\Desktop>py -m nsist installer.cfg
Traceback (most recent call last):
  File "C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nsist\__main__.py", line 2, in <module>
    main()
  File "C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nsist\__init__.py", line 527, in main
    shortcuts = configreader.read_shortcuts_config(cfg)
  File "C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nsist\configreader.py", line 182, in read_shortcuts_config
    appcfg = cfg['Application']
  File "C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\configparser.py", line 956, in __getitem__
    raise KeyError(key)
KeyError: 'Application'

我在 Windows 10 64 位 Python 3.6.0 上 运行 宁此。

问题原来是配置文件被称为 installer.cfg.txt,而不是 installer.cfg

如果您遇到类似问题,请仔细检查配置文件是否位于正确位置,以及名称是否与您在命令行中输入的内容相匹配。请记住,某些程序(如 Windows Explorer)可能会隐藏已知的扩展名,因此您看到的可能不是真实的文件名。使用终端或命令提示符通常会显示真实姓名。

当配置文件不存在时,我将制作 Pynsist give a clearer error