-
Notifications
You must be signed in to change notification settings - Fork 824
Pywin32 - DLL load failed while importing _win32sysloader #2580
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
Comments
These paths look strange to me. |
Sorry for the misunderstanding for the filepaths, I changed the paths to the following: #Imports import win32com.client And, I still run into the same problem. |
This means Windows failed to load _win32sysloader.pyd due to a missing import - most likely
I don't know what win32ctypes is, but the fact it has a |
FYI |
First of all, thank you all so much for your responses! I double checked and _win32sysloader.pyd was loaded to the win32 folder. Also, I believe that my system is using the correct pythonXX.dlls because it uploaded it to the correct place, I also double checked the paths just in case. The 'win32ctypes' error was my mistake, I apologize for that but, it has been removed from my code and it is not in the Venv. That being said, I have started a new Venv on the C: drive named env (I removed all other references I could find related to pywin32). I used python3.13 to create the environment and pip3.13 to install pywin32. I am using Revit 2025, with dynamo's python version 3.9.12 (which I'm not sure if that should make a difference) to run the codes below: Here's the cmd process:
and the python code with python version 3.9.12:
I believe this cleaned everything up properly but, I am still getting the same error. I'm at a loss because it appears that everything should be working properly. |
I'm wondering why you need to append these paths at all in your Python code when you run it in the activated venv where you also installed pywin32? |
Yeah, this seems suspicious - if those paths aren't on |
Just to make sure we're all on the same track. Could you send the actual locations as printed by |
If it's any consolation, I got it to work by installing python 3.9 and I used that to install it. However, I'm worried because I am going to need to install this firmwide to access the users Microsoft Outlook app and want it to work correctly because I am not sure what they have installed on their machines even though I'm presuming they have the same folder %localappdata%\python-3.9.12-embed-amd64 and they shouldn't have any versions of python installed because we're all using Revit Dynamo to run the scripts. Plus, I am going to need to update it for every version of Revit moving forward.
I tried to use the above command and I got the following error in the cmd prompt:
I also keep checking all the sys.path from the Environment Variables and it just points to the python.exe files in %USERPROFILE%\AppData\Local\Microsoft\WindowsApps (python.exe & python3.exe), the dlls I've found on the sys.path are for other programs, i.e. Visual Studio etc. FYI, I'm going to attempt to install pywin32 on everyone's machine in their %localappdata%\python-3.9.12-embed-amd64 folder so they can use the package, but I want this to work correctly first. |
That means there's no "python" executable currently on your
There also seems to be some known(-ish) issue with the Microsoft Store installation, refer to #1383 |
Okay, I think I did what you asked and got the following response:
|
Is pywin32 installed? I see you're using an embed install, but that's not quite the same error as #1916 . Looks similar to #1618 (assuming you do have pywin32 installed) This comment seems especially relevant: #1618 (comment)
|
Okay, I researched the comments above
and think I finally figured it out. Even though this code doesn't install pywin32 into a virtual environment, it installs it locally per user and that should work theoretically/hopefully right? I still need to test it out on a few of my coworkers before I get confirmation though. Here's my code:
I'm not sure if it will work for everyone in our firm but, I feel much more confident that it will. I also still need to append the win32 and win32\lib paths because it doesn't find pywintypes or _win32sysoader without appending them however, it seems to be working fine now. Once I test it and add a couple of failsafe checks it should be ready to release to the firm. Do you think it will be okay per user or should I be doing something different? |
Looks like you have to append to your path because
# .pth file for the PyWin32 extensions
win32 # can do `import winxpgui` instead of `import win32.winxpgui`
win32\lib # can do `import winerror` instead of `import win32.lib.winerror`
Pythonwin # can do `import win32ui` instead of `import pythonwin.win32ui` And 1 dynamic code execution to register dll locations: # And some hackery to deal with environments where the post_install script
# isn't run.
import pywin32_bootstrap Which loads this module: https://github.com/mhammond/pywin32/blob/main/win32/Lib/pywin32_bootstrap.py (everytime you import anything) |
I tried all of these suggestions and in different configurations (even tried installing pywin32 directly inside the python-3.9.12-embed-amd64 folder as per your post in #1618 (comment)) and the easiest /best thing for me is just to append the paths like I did previously. I'm not sure if this will work for everyone until I get it tested. The issue seems to be that the python39.pth file doesn't seem to be finding the Lib folder and pywin32.pth file for some reason even when I have appended the site-packages path in the main code
and even when I appended them to the python39.pth file (unless I've been doing it wrong because I can't get it to work correctly) so, I would think it should be able to read the pywin32.pth file when win32com is called but, it doesn't seem to be finding the pywin32.pth file. |
Hello there :)
First of all, I hope this is the correct place for this request, if not, please let me know and I can put it where it belongs.
I tried to import win32com.client using Revit 2025's dynamo V.3.3.0 with Revit's preinstalled python 3.9.12 so I could send Emails because the marshal app has been downgraded. The best and easiest way I can see to get access the Outlook Application is to use win32com.client. I am trying to import it and it keeps throwing the error that _win32sysloader can't be found. I'm new to downloading packages for my scripts so, I'm not sure if I'm doing it correctly but, I've tried creating a Venv several times and installing pywin32 with different pythons and pips, e.g. python, python3, python3.13, pip, pip3, pip3.13. I can't figure out what's wrong and I keep running into the same issue.
Any help you could offer me in fixing this error would be greatly appreciated!
Expected behavior and actual behavior
I would think win32com.client could be imported
Actual behavior is Error Message: DLL load failed while importing _win32sysloader: ... "\lib\pywintypes.py", line 50, in import_pywin32_system_module\n import _win32sysloader
as you can see in my code below, I needed to append the path to find the other dlls etc. as well.
Steps to reproduce the problem
#Imports
#-------
import clr
import sys
sys.path.append(r'C:\Users##\OneDrive - MoodyNolan, Inc\Desktop\Venv\newenv\Lib\site-packages')
sys.path.append(r"C:\Users##\OneDrive - MoodyNolan, Inc\Desktop\Venv\newenv\Lib\site-packages\win32")
sys.path.append(r"C:\Users##\OneDrive - MoodyNolan, Inc\Desktop\Venv\newenv\Lib\site-packages\win32\lib")
sys.path.append(r"C:\Users##\OneDrive - MoodyNolan, Inc\Desktop\Venv\newenv\Lib\site-packages\win32ctypes\pywin32")
sys.path.append(r"C:\Users##\OneDrive - MoodyNolan, Inc\Desktop\Venv\newenv\Lib\site-packages\win32ctypes")
import win32com.client
System information
Python version and distribution:
<python 3.13 & 3.9.12>
pywin32 version:
pywin32-310
Windows Version:
<Version 10.0.19045 Build 19045>
DLL locations:
installed with pip3.13 into Venv 'newenv' listed in the code above so all DLLs should be there except for the _win32sysloader.dll, however, _win32sysloader.pyd is located under win32 in the site-packaged folder.
The text was updated successfully, but these errors were encountered: