Import win32api error in Python 2.6

When running python26 under Windows (64 bit) ..... I have errors like:

import win32api" error in Python 2.6: pywintypes26.dll 

or

 pythoncom26.dll missing ImportError: DLL load failed: The specified module could not be found. 

I installed msi for python26 all the dll files can be found in the folder C: \ Python26 \ Lib \ site-packages \ pywin32_system32

+54
python pywin32
Aug 30 2018-11-11T00:
source share
11 answers

After I copy pywintypes26.dll and pythoncom26.dll from C: \ Python26 \ Lib \ site-packages \ pywin32_system32 to C: \ Python26 \ Lib \ site-packages \ win32 → Solve the problem!

+65
Sep 02 2018-11-11T00:
source share

I also ran into import problem win32api.

The post-installation script for pywin32 failed, and, among other things, you need to copy pythoncom26.dll , pythoncomloader26.dll and pywintypes26.dll . I started it manually and my installation was fixed.

 python scripts\pywin32_postinstall.py -install 
+35
Feb 04 '14 at 21:37
source share

I had a similar problem when installing under 64-bit Python 3.4.2. I ran the install pywin32-219.win-amd64-py3.4.exe executable from http://www.lfd.uci.edu/~gohlke/pythonlibs/ .

The site clearly states:

"Python 3.4 users must manually run python.exe Scripts\pywin32_postinstall.py -install from an elevated command prompt."

which I did not do for the first time; I installed the following feedback from a regular request:

 c:\python34>python.exe Scripts\pywin32_postinstall.py -install Copied pythoncom34.dll to C:\Python34\pythoncom34.dll Copied pywintypes34.dll to C:\Python34\pywintypes34.dll You do not have the permissions to install COM objects. The sample COM objects were not registered. etc.etc. Finishing with "The pywin32 extensions were succesfully installed" ... 

I just read the last sentence, and I started to run some code that caused the loading of these DLLs to fail.

So, I did some research and started an elevated prompt (like: see http://www.sevenforums.com/tutorials/783-elevated-command-prompt.html ") and ran again:

 c:\python34>python.exe Scripts\pywin32_postinstall.py -install Copied pythoncom34.dll to C:\Windows\system32\pythoncom34.dll Copied pywintypes34.dll to C:\Windows\system32\pywintypes34.dll Registered: Python.Interpreter Registered: Python.Dictionary Registered: Python -> Software\Python\PythonCore\3.4\Help[None]=None -> Software\Python\PythonCore\3.4\Help\Pythonwin Reference[None]='C:\\Python34\\Lib\\site-packages\\PyWin32.chm' Pythonwin has been registered in context menu Shortcut for Pythonwin created Shortcut to documentation created The pywin32 extensions were successfully installed. 

And now my code works happily (as far as the question is concerned ... sigh, much more).

+10
Nov 28 '14 at 10:20
source share

Run the installer as Administrator and it works:

  • Right click on pywin32-installer.exe
  • Select "Run as administrator"
+7
Mar 20 '15 at 13:25
source share

As mentioned above, the script does not start after installation, this problem can be seen when installing from the wheel (as I discovered)

 python scripts\pywin32_postinstall.py -install 

If you find that you have this problem when installing with the wheels, then installing it from here can solve the above problem.

https://pypi.python.org/pypi/pypiwin32

+6
Feb 08 '16 at
source share
+2
Aug 27 '14 at 13:16
source share

I could fix this by uninstalling all installed versions of Python3.4 (I forgot to uninstall 3.4.1 before installing 3.4.2), uninstalling C: \ Python34 and after installing Python 3.4.2 pywin32-219.win32-py34.exe could be installed and called without problems. Therefore, copying the DLL does not have to be necessary!

+2
Nov 26 '14 at 8:04
source share

I always install the Active State Python distribution, which installs win32 packages for you and fixes them.

+1
Aug 30 '11 at 6:28
source share

If the above does not fix the problem, you still miss the msvcr100.dll file. This is either in your \System32\ , or most likely in your c:\PythonXX\Lib\site-packages\win32\ folder.

This fixed it for me after several hours of searching to no avail, although it seems that the import is still not allowed, as it should be (PyCharm still gives me an underlined underline), but it works.

+1
Feb 23 '17 at 19:14
source share

I am not too late or do not answer this question. I also ran into this problem and I tried each method above but none of them worked.
Finally, I found the reason. When we install pywin32 , we must choose the one that is suitable for the python version (2.6, 2.7, 3.3, etc.) and the python bit number (x64 or x86). Please note: it must match the python bit number, not the computer bit number. If you are installing python x86 on an x64 PC, you need to install pywin32 with x86.

+1
Sep 14 '17 at 5:39 on
source share

At first I used pip to install pywin32 in anaconda environment, so no matter what I did, it did not work. After trial and error, I realized that conda install pywin32 right way to install pywin32 in the anaconda package manager

0
Sep 24 '19 at 4:27
source share



All Articles