Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

Error message

Today to share with you an absolute absolute dry goods, this dry goods is my own personal practice, the Internet absolutely can not find the kind of. A little background. Recently, I developed a calendar desktop application with calendar reminders using Python’s Tkinter library. At the end of the development of the program to start packaging, only to find that the error kept coming

PyInstaller cannot check for assembly dependencies.
Please install PyWin32 or pywin32-ctypes.
pip install pypiwin32
Copy the code

However, running PIP install pypiwin32 prompts you that both libraries are already installed

But when running the package script is dead or alive cannot package, is a reminder of the lack of the above two dependent libraries.

All kinds of Baidu found no similar strange situation, I want to hit the computer, but not the computer hit the meat pain, and still eat guy, can not only think of another way.

So decided to solve their own, first according to the error keyword to pyInstaller source to retrieve the location of the error.

In the end, it was found that the problem was caused by the guide package. The two dependent libraries had been installed but the import method was different, which led to the error.

The solution

The python installation directory contains a compat.py file in the Lib/site-packages/Pyinstaller directory at line 212

The source code is as follows:

if is_win:
    try:
        from win32ctypes.pywin32 import pywintypes  # noqa: F401
        from win32ctypes.pywin32 import win32api
    except ImportError:
        xxxx
        xxxx
Copy the code

Make the following changes: change the two from to import

if is_win:
    try:5
        # from win32ctypes.pywin32 import pywintypes  # noqa: F401
        # from win32ctypes.pywin32 import win32api
        import pywintypes
        import win32api
    except ImportError:
        xxxx
        xxxx
Copy the code

Then re-run the package script and the package succeeds