takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
930 stars 123 forks source link

Unable to run shortcut created by installer - Tkinter test application #206

Closed echu87 closed 4 years ago

echu87 commented 4 years ago

I have been trying to create an installer for a simple Tkinter test application and have had trouble running the shortcut that it creates.

Config file:

[Application]
name=pynsist_test
version=1.0

entry_point= main:run

[Python]
version=3.7.4
bitness=64

[Include]

packages=
    tkinter
    _tkinter

files=lib 

folder structure: filestructure

folder created after the installation: folders

This folder looks correct according to https://pynsist.readthedocs.io/en/latest/faq.html#packaging-with-tkinter, and I have made sure that my bitness and python version is correct.

When I run the shortcut, nothing happens. If anyone has run into a similar problem your help would be greatly appreciated.

takluyver commented 4 years ago

Nothing happening when you click the shortcut usually means there's an error as it starts. This will be written to a log file: https://pynsist.readthedocs.io/en/latest/installers.html#uncaught-exceptions

echu87 commented 4 years ago

When I run the test launch I run into the following error:

Traceback (most recent call last):
  File "pynsist_test.launch.pyw", line 34, in <module>
    from main import run
  File "pkgs\main.py", line 1, in <module>
    import tkinter as tk
  File "pkgs\tkinter\__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: DLL load failed: The specified module could not be found.

This is strange because the install directory contains the lib and pkgs folder (pics in the previous comment) that seems correct from the explanation in the documentation.

takluyver commented 4 years ago

That error message means that some DLL needed by Tkinter isn't there. Unfortunately, the error fails to say what DLL. Sometimes it's possible to work it out with a program called dependency walker.

Unfortunately tkinter is kind of a weird corner case for Pynsist. Because it's normally part of the standard library, it's not packaged on PyPI. But it's not included in the 'embeddable' Python build that Pynsist bundles with your application. So we don't have any good way to get it. The information in the FAQ is what someone else had to do to make it work, but maybe there's some detail missing or something that is different for different Python versions.

takluyver commented 4 years ago

I've added an FAQ entry about that kind of error, as well as the existing entry about Tkinter.

https://pynsist.readthedocs.io/en/latest/faq.html#dll-load-failed-errors