How do I install pywin32 for ArcGIS Pro 3.0? It worked for me in 2.x, but in 3.0, the installation fails whether trying it from the Pro user interface (Settings > Package Manager > Add Packages) or in a Python command prompt using conda install or pip install. There seems to be a lot of conflicts in dependency versions. After attempting to install, if I run this code:
from win32com import client
I get:
ImportError: DLL load failed while importing pythoncom: The specified procedure could not be found.
I'm using pywin32 and arcpy to update an APRX and an Excel file and export sheets from Excel to PDF.
Solved! Go to Solution.
The solution I found:
Now I can use pywin32. That last step was a tip I gleaned from Gohlke's wheel page.
This was done on a virtual machine. On my physical machine, the admins have some security thing going on that prevents me from installing the pywin32 package, but others may not encounter such an issue.
Your attempts to install what is already there (at least parts of it) may have had undesireable consequences.
from win32com import client
dir(client)
['CDispatch', 'CLSIDToClass', 'CastTo', 'CoClassBaseClass', 'Constants',
'Dispatch', 'DispatchBaseClass', 'DispatchEx', 'DispatchWithEvents', 'EventsProxy', 'GetActiveObject', 'GetObject', 'Moniker', 'Record',
'VARIANT', 'WithEvents', '_PyIDispatchType', '__WrapDispatch', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__',
'__name__', '__package__', '__path__', '__spec__', '_event_setattr_',
'_get_good_object_', '_get_good_single_object_', 'build', 'constants',
'dynamic', 'gencache', 'getevents', 'pythoncom', 'pywintypes', 'sys']
Delete your clone (or reinstall Pro if you tried this in base.
>>>conda install xxxxxx --dry-run
Is a useful step to anticipate installation issues beforehand.
I was working in a clone. I switched back to base (arcgispro-py3) and get this in a Python command prompt.
(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>python
Python 3.9.11 [MSC v.1931 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from win32com import client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'win32com'
I'm in Pro 3.0.0. Is it possible that attempting to install pywin32 in the clone corrupted the base installation?
I am using 3.0.2.
I can't remember when pywin32 stuff appeared.
Messing with the clone can't affect the base environment.
You can also look at
Welcome to PyPDF2 — PyPDF2 documentation
xlrd — xlrd 2.0.1 documentation
xlwt documentation — xlwt 1.3.0 documentation
for other options if you can resolve, they are installed by esri and I think used somewhere in the Pro ecosystem.
Thanks for the other things to look at but I don't think they handle exporting PDFs from Excel.
With a clean install of Pro 3.0, I upgraded to 3.0.2, and I still don't have pywin32 installed. A search for "win" in the Package Manager in Pro reveals these libraries that seem close but not quite it:
* python-certifi-win32
* pywin32-security
For an import test, this time I tried from within a Python console window in Pro. I get "No module named 'win32com'". I wonder how you have pywin32 but I don't.
The solution I found:
Now I can use pywin32. That last step was a tip I gleaned from Gohlke's wheel page.
This was done on a virtual machine. On my physical machine, the admins have some security thing going on that prevents me from installing the pywin32 package, but others may not encounter such an issue.
Hi Tim,
I am currenlty using arcGIS pro version 3.3.1 and the package "pywin32" isn't available to add. Do you know why or any work around to get pywin32 package installed in this version.
I'm having the same issue as you Emma and Tim. Prior to updating to Pro v3.3.1 I was able to install PythonWin which also installs pywin32... and I've always installed to the base Python install. PythonWin seems to install but errors out now upon attempting to start the PythonWin IDE (error message: "The application can not locate Python39.dll (126) The specified module could not be found"). Also, perhaps more concerning, other modules I use that depend on pywin32 such as 'pyad' (Python access to MS Active Directly) and 'win32com' (Excel) all error out now:
Python 3.11.8 (main, Mar 22 2024, 13:25:41) [MSC v.1938 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from win32com import client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\win32com\__init__.py", line 8, in <module>
import pythoncom
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\win32\lib\pywintypes.py", line 126, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\win32\lib\pywintypes.py", line 52, in __import_pywin32_system_module__
import _win32sysloader
ImportError: DLL load failed while importing _win32sysloader: The specified module could not be found.
I was able to install it in ArcGIS Pro using a pip install as follows:
1) Open the command prompt by typing “command prompt” or cmd in the Windows search.
2) Assuming your Python cloned environment is in the default location, type this command* (inserting your own username in the path):
C:\Users\[yourUsername]\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\python.exe -m pip install pywin32
If you are not using the default location, alter the file path to where your own clone is stored. For example, if my username is Elmer and I created a clone in this location, C:\Users\Elmer\AppData\doubletree\arcgispro-py3-myclone2, I would use this command:
C:\Users\Elmer\AppData\doubletree\arcgispro-py3-myclone2\python.exe -m pip install pywin32
3) Navigate to the file in which pywin32 has been downloaded (your cloned environment > Lib > site-packages > pythonwin)
4) Open Pythonwin.exe and try importing arcpy.
I'm still on 3.2, where the previous solution I posted worked. If anything changes once I migrate to 3.3, I'll share results here. I think Esri prefers you to make a clone of the default environment, and add packages to the clone rather than modify the default environment. But if you found a solution that worked, then hooray!