1

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.

TheStrangeQuark
  • 2,257
  • 5
  • 31
  • 58
  • That's weird. Can you try editing `C:\Users\Mike\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nsist\configreader.py` and put `print(dict(cfg))` in before line 182? The output from that should help to see what's going on. Also, have you edited the `installer.cfg` file at all? – Thomas K Mar 02 '17 at 11:05
  • Yes, it prints `{'DEFAULT': }`. I have not edited the `installer.cfg` file at all. – TheStrangeQuark Mar 02 '17 at 18:47
  • Ah, I think the config file is not there. It looks in the directory where you are in the prompt (that's the Desktop folder, in your example). If your cfg file is somewhere else, you can use `cd` to navigate to the location where your files are. It should give a clearer error when it can't find the file - I'll fix that. – Thomas K Mar 03 '17 at 12:26
  • I have my installer.cfg file and the python script both on my desktop. Should I move them to a different directory together? – TheStrangeQuark Mar 03 '17 at 14:22
  • If you run `dir` in the command prompt just before running `py -m nsist installer.cfg`, does it show the file there? – Thomas K Mar 03 '17 at 16:57
  • Oh know! the file is called `installer.cfg.txt`! I'm not sure how I missed this, I even checked dir when I ran into the problem and must've ignored that. – TheStrangeQuark Mar 04 '17 at 00:18
  • @ThomasK I've noticed you answer all the pynsist questions, are you the developed? I have another question but don't want to make a new question regarding pynsist. Can I contact you in some way? – TheStrangeQuark Mar 04 '17 at 00:24
  • I am the developer! :-) I prefer to answer questions in a public forum (make a question here on SO, or open a Github issue), because then the answers are useful to other people who might have a similar problem. If you need to send me some private info about a problem, you can use the email address on my [Github profile](https://github.com/takluyver/). – Thomas K Mar 04 '17 at 13:56

1 Answers1

2

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.

Thomas K
  • 39,200
  • 7
  • 84
  • 86