-
Notifications
You must be signed in to change notification settings - Fork 799
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 win32event: The specified module could not be found. #1431
Comments
Same. |
Seems to be a Python 3.8 specific problem, I have the same thing: > python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32file
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing win32file: The specified module could not be found. |
|
Registering pywin32 with the system with |
Hmm. But that doesn't seem to happen automatically when installing. I thought postinstall scripts were supposed to be automatic? But even if it were automatic, it doesn't provide a method for making a "portable" installation of Python that can be moved from machine to machine, or shared on a cloud-synchronized installation, so a better solution that allowed for portability would be far preferable. |
It does if you use the installer, but due to limitations with wheels, it doesn't when using them.
pywin32 has features which makes that impossible in the general case, such as implementing COM servers or Windows services. Things "mostly" work pre 3.8, but Python seems to have made changes in that version which mean pywin32 needs to change how it does things. |
Interesting, regarding wheels and postinstall. I thought wheels solved all the world's install problems :( I can understand that COM servers and Windows services might require registration, but I venture to guess that most users of pywin32 aren't doing that, and that if they are, they'd know the need to register. Yes 3.8 changed the rules for searching for DLLs on various paths. One has to call os.add_dll_directory. It is described in the 3.8 What's New, and a link to the PEP or something. Code like this enables access from outside pywin32, but would be better built in to pywin32 somehow...
|
I told that to be code, why did it mangle it?
|
Plain quoting worked better. I am not a GitHub expert, sorry. |
I believe the reason the postinstall doesn't run automatically is because it requires elevated privileges, so it wouldn't work in a venv. It does specify this in the README, however. |
@CircuitCraft42 You might be right about postinstall in venv, but I installed from a wheel as administrator, not in a venv, and postinstall doesn't run then either. |
Yeah, same. I don't know how hard it is to detect privileges and/or selectively run postinstall scripts. |
Personally, I would want postinstall scripts to be able to be optional, for the cases where you don't really need them. And for my uses of pywin32, I don't need registration, I just need to be able to load the DLLs, and I'd prefer to be able to do that without registration, so I can use the parts I use in a portable fashion. |
This directory is now added to the start of PATH for version 3.7 and earlier, and passed to os.add_dll_directory() on 3.8 and later. This will hopefully work around problems loading pywintypes.dll in various situations. Fixes mhammond#1432, fixes mhammond#1431
For python 3.8.3, pywin32==225 worked for me, the existing pywin32==228 was uninstalled. |
How can I make this work in a portable app, e.g. made with PyInstaller? I've tried a few different versions of pywin32 and I always get this error. I'm using Python 3.7 from Windows Store. I also get an error with the postinstall script
|
There are reports of issues with python from the python store - I'm yet to play with it. I suspect it doesn't put the DLLs where pywin32 expects. |
I installed the official version instead of the Microsoft store and now it's working. |
thanks you a lot ! 64bit of win10, python3.7 it's ok |
This works .. Thanks for the advice you saved me a lot of work .. I am on python 3.8.5 |
I tried uninstalling python and acaconda, then reinstalling anaconda + python within anaconda and this worked |
It worked for me! Using Python 3.8.5 had thee DLL issue on Jupyter Notebook and after installing |
Thank you~~ |
Summary: Fixes Windows build after it was broken due to iopath dependency inclusion. Latest version of pywin is not compatible with python3.8, so we need to fix it at v225. Reference : [issue](mhammond/pywin32#1431). Pull Request resolved: #758 Reviewed By: ytsheng Differential Revision: D26171059 Pulled By: vedanuj fbshipit-source-id: 332281c7987a8ba9cdb4cc3ec38f23476a2af146
I had this issue and solved it in a way I had not seen documented anywhere else. Python 3.7 does not seem compatible with pywin32==301. I am coding a windows .bat script to set up a venv. I will edit this post with a link to my project once I release it. System ConfigurationI am using PyCharm 20.3.3 Community Edition as my IDE.
Also, I have several virtual environments. My project venv created by PyCharm uses 3.9.0 My Original .bat Script (Broken)
However, I kept getting the import DLL error. I used winmerge to compare between the PyCharm-created venv and the comamnd-line created venv and found that '37.pyc' files were created instead of '39.pyc' I added a
Silly me... why was I using python3 instead of python? My Fixed .bat Script (Working)I removed the "3" from the python command. My venv command installed version 3.9 correctly and ran my code without issue.
AnalysisMy python 3.9 installation does not include a "python3.exe". My guess is that a lot of legacy code/scripts are using the "python3" command instead of "python". This is exactly what I did... I rarely execute python from the Windows command line. Again, |
I suspect the problem here will be more like "Windows AppStore installed Python isn't compatible with pywin32" - I'll try and find time to dig into this some more. |
yes, it also solved my problem. Thanks for the help. |
on windows10 python 3.8, use This worked for me. |
Getting the same issue on the latest Python version. Anyone else have any solutions? The above haven't worked for me |
There's a chance that the release version of python 3.11 has issues, so try 3.10 until I get a new build out (which I'm slowly working on but is turning out to be non-trivial) |
@mhammond Sorry. I meant the latest public release(3.10.5). I figured the pre-release would have issues. Is there a confirmed working version of Python or a working solution? Also, are you having to do this for every release as this issue as been here since 2019 and was previously closed |
Every example of this that I have seen has been explained by duplicate installs of pywin32 such that there are multiple copies of the DLLs - have you seen https://github.com/mhammond/pywin32/blob/main/README.md#the-specified-procedure-could-not-be-found--entry-point-not-found-errors? |
@mhammond So, the post_install script is installing pythoncom37 and pywintypes37 instead of 310 or whatever the latest version is. It gets put into SysWOW64. I've been dragging it into my venv\site-packages but I'm now using python 3.10.5. Should I uninstall 3.7? Edit: Uninstalled older versions. Now getting correct 310 dlls. Need to move them now... edit2: Moved the .dls to two locations. The first being Appdata/.../site-packages/win32 and the second being venv...\win32. The program still gives me win32api module does not have getCursorPos() and pycharm gives me an error that win32api module doesn't exist. It finds win32con though |
That must have been because you used python 3.7 to run the post-install script. Re your other issues: |
I just installed Python 3.8.0 32-bit, then installed a few modules including pywin32 using pip.
When I try "import win32event", I get the following error:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
The same happens when I try "import win32com".
Since I found this http://www.xavierdupre.fr/blog/2014-07-01_nojs.html , I tried adding c:\python3.8.0-32\lib\site-packages\pywin32_system32 to my path and then restarting cmd and importing win32event again and still got the same error.
I also tried adding
path = os.path.join(os.path.split(sys.executable)[0], "Lib","site-packages","pywin32_system32")
os.environ["PATH"] = os.environ["PATH"] + ";" + path
before calling qt5reactor.install() #(which is what's trying to load win32event), and that didn't work either.
I also have Python 2.7 and Python 3.6 installed, but I don't seem to to have pywin32 installed on those versions of Python.
I saw that a similar issue had been submitted, but it seems that it was decided that that error was due to some custom installation, and in my case there was no custom installation.
I just tried copying the dll's in c:\python3.8.0-32\lib\site-packages\pywin32_system32 to c:\python3.8.0-32, and now the import statement works.
The text was updated successfully, but these errors were encountered: