Win32api problems

Eryk Sun eryksun at gmail.com
Tue Oct 22 14:25:45 EDT 2019


On 10/22/19, Albert-Jan Roskam <sjeik_appie at hotmail.com> wrote:
> On 22 Oct 2019 11:23, GerritM <gerrit.muller at gmail.com> wrote:
>
>> ImportError: DLL load failed: The specified > procedure could not be
>> found.

Many of the PyWin32 extensions depend on pywintypesXX.dll, and some
depend on pythoncomXX.dll. There's a post-installation script that
copies them either to the System32 directory or to Python's
installation directory (i.e. the location of python.exe). The latter
is better if you're doing this manually. There's no reason to pollute
System32.

If you're developing a service, pythonerservice.exe depends on
pythonXX.dll, so copy pythonservice.exe to Python's installation
directory as well if pythonXX.dll is located there instead of in
System32.

You can use relative symlinks instead of copies if Python is installed
on a file system that supports reparse points, such as the system
volume (NTFS). For example:

    >>> print(os.readlink(os.path.join(sys.prefix, 'pywintypes37.dll')))
    Lib\site-packages\pywin32_system32\pywintypes37.dll

Then if you upgrade PyWin32, you won't have to remember to replace the
old copies.

> I've had the same error before and I solved it by adding the location where
> the win32 dlls live to PATH. Maybe PATH gets messed up during the
> installation of something.

In Python 3.8, PATH isn't used when loading extension modules. It's
also not used when loading DLLs via ctypes. In many cases this change
isn't an issue since dependendent DLLs are in the same directory as
the extension module. If not, add the directory that has the
dependencies via os.add_dll_directory().



More information about the Python-list mailing list