简体   繁体   中英

KeyError when using Pynsist

I'm trying to replicate the following example: https://github.com/takluyver/pynsist/tree/master/examples/tkinter but it is not working. I have a python file and .cfg that are copy pasted from here, but when I run py -m nsist installer.cfg on my command prompt, I get the following error:

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'

I am running this from Python 3.6.0 on Windows 10 64-bit.

The issue turned out to be that the config file was called installer.cfg.txt , rather than installer.cfg .

If you're having a similar issue, double check that the config file is in the right place and the name matches what you're typing at the command line. Remember that some programs (like Windows Explorer) might hide known extensions, so what you see might not be the real file name. Using a terminal or command prompt will usually show you the real name.

I'll make Pynsist give a clearer error when the config file isn't there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM