Search code examples
pythonwinapipyinstallerpywin32

__main__.pyinstallerimporterror failed to load dynlib/dll "shcore"


I use pyinstaller to pack a exe file.

It can run normally in my computer(Win 10).

But in another person's computer(Win 7),it shows that

__main__.pyinstallerimporterror failed to load dynlib/dll "shcore".

About shcore,I use

import ctypes
PROCESS_PER_MONITOR_DPI_AWARE = 2
ctypes.windll.shcore.SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)

What should I do? Thanks in advance.


Solution

  • Minimum supported client for SetProcessDpiAwareness is Windows 8.1.

    And according to the PROCESS_DPI_AWARENESS:

    In previous versions of Windows, there was no setting for PROCESS_PER_MONITOR_DPI_AWARE. Apps were either DPI unaware or DPI aware. Legacy applications that were classified as DPI aware before Windows 8.1 are considered to have a PROCESS_DPI_AWARENESS setting of PROCESS_SYSTEM_DPI_AWARE in current versions of Windows.

    You can only use SetProcessDPIAware to set System DPI Aware