Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: DLL load failed while importing win32gui: The specified procedure could not be found #1730

Closed
mosaleh52 opened this issue Jul 6, 2021 · 9 comments

Comments

@mosaleh52
Copy link

when trying to import win32gui or win32api this is the output error
'''
C:\Users\m\Desktop\auto timer>main.py
Traceback (most recent call last):
File "C:\Users\m\Desktop\auto timer\main.py", line 3, in
import win32gui
ImportError: DLL load failed while importing win32gui: The specified procedure could not be found.
'''
after install pywin32 for the first time it was working but now it doesn't
what i have tried to solve this proplem:
----- reinstall pywin32 (it dosnot work )
-----create a conda env it doesn't work ( i have python installed seperatly , mini conda for ven only )
her is my system info
OS Name: Microsoft Windows 10 Home Single Language
OS Version: 10.0.19042 N/A Build 19042
Python 3.9.5
Name: pywin32
Version: 301
conda 4.10.3

@primal100
Copy link

primal100 commented Jul 7, 2021

I'm getting a similiar issue with pywin32 v301.

DLL load failed while importing win32security: The specified procedure could not be found.

Works fine in pywin32 v300.

Windows 10 build 18363, python 3.8.6

@mmaylat
Copy link

mmaylat commented Jul 7, 2021

I'm getting identical issues for python 3.6 versions with pywin32-301.

Don't see any problem with higher python versions.

@mosaleh52
Copy link
Author

@mmaylat @primal100 after uninstall with pip then creating conda env with reboot it worked (pywin32 is defult installed in conda env)

@grgeorgeivanov
Copy link

grgeorgeivanov commented Jul 12, 2021

We are also seeing this on Python 3.6.6, during import requests_negotiate_sspi with pywin32==301. Works fine with <300

@elbakramer
Copy link
Contributor

elbakramer commented Jul 22, 2021

Getting similar issue when installed via pip.

$ pip install pywin32==301

System background:

  • windows 10
  • conda 4.10.1
  • python 3.8.8 (64bit)
  • pywin32-301

One of the workarounds that actually worked was just to downgrade to version 300:

$ pip install pywin32==300

or revert to initial conda distribution (version 228):

$ conda install pywin32

Another was to remove any existing dlls and copy valid ones in sys.prefix folder:

import os
import sys
import glob
import shutil
import distutils.sysconfig

lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1)

files = glob.glob(os.path.join(lib_dir, "pywin32_system32\\*.*"))
bases = [os.path.basename(file) for file in files]

bad_dest_dirs = [
    os.path.join(sys.prefix, "Library\\bin"),
    os.path.join(sys.prefix, "Lib\\site-packages\\win32"),
]

for base in bases:
    for bad_dest_dir in bad_dest_dirs:
        bad_fname = os.path.join(bad_dest_dir, base)
        if os.path.exists(bad_fname):
            os.unlink(bad_fname)

for file in files:
    shutil.copy(file, sys.prefix)

@mhammond
Copy link
Owner

I suspect this will work better in build 303, but please reopen if it doesn't (but see also https://github.com/mhammond/pywin32#the-specified-procedure-could-not-be-found--entry-point-not-found-errors)

@marxangels
Copy link

import pywintypes # Not used, but need it for win32gui to import correctly
import win32gui

stackoverflow

@PetteriAimonen
Copy link

Note for people hitting this after upgrading to pywin32 version 305:

The way pywintypesXX.dll is searched was changed by commit 50c3113.
This causes the file to be moved under pywin32_system32 subdirectory when packaged by e.g. pyinstaller.
This may need changes in installation scripts to make sure the old incompatible files do not stay lingering after upgrade.

@tomate1
Copy link

tomate1 commented Mar 29, 2023

Getting similar issue when installed via pip.

$ pip install pywin32==301

System background:

  • windows 10
  • conda 4.10.1
  • python 3.8.8 (64bit)
  • pywin32-301

One of the workarounds that actually worked was just to downgrade to version 300:

$ pip install pywin32==300

or revert to initial conda distribution (version 228):

$ conda install pywin32

Another was to remove any existing dlls and copy valid ones in sys.prefix folder:

import os
import sys
import glob
import shutil
import distutils.sysconfig

lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1)

files = glob.glob(os.path.join(lib_dir, "pywin32_system32\\*.*"))
bases = [os.path.basename(file) for file in files]

bad_dest_dirs = [
    os.path.join(sys.prefix, "Library\\bin"),
    os.path.join(sys.prefix, "Lib\\site-packages\\win32"),
]

for base in bases:
    for bad_dest_dir in bad_dest_dirs:
        bad_fname = os.path.join(bad_dest_dir, base)
        if os.path.exists(bad_fname):
            os.unlink(bad_fname)

for file in files:
    shutil.copy(file, sys.prefix)

this was helpful to me
306 release broke my code
python cant find pywintypesXX anymore

I embed python in another application using Py_RunSimpleString.

on version 305 everything works and the dlls are found there in ..Lib\site-packages\pywin32_system32

But on release 306 the dlls are simply not found anymore

I downgraded because it was easier in my case, I believe that copying to sys.prefix should work aswell
But this is really annoying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants