[Solved] ModuleNotFoundError: No module named ‘win32api’

This is the error received:

    Traceback (most recent call last):
  File "C:/Users/Joe Martin/AppData/Local/Programs/Python/Python37/", line 12, in <module>
    import win32com.client
  File "C:UsersJoe", line 5, in <module>
    import win32api, sys, os
ModuleNotFoundError: No module named 'win32api'

This error occurs when trying to import the win32com.client module.

Solutions Tried:

  • Fresh wipe and install of Python 3.7
  • pip install pypiwin32
  • pip install pywin32
  • Running the

I cannot find any other solution for how to fix this issue.

Solution #1:

This is usually because no PythonPath is appended after the package is installed.
Check the file–pywin32.pth under the folder–\PythonVersion\Lib\site-packages\.

The content in the file is like below:

# .pth file for the PyWin32 extensions
# Entries needed for a "portable" installations, where the post_install script
# isn't run, which would normally copy the pywin32 core DLL files to either
# the top of the python directory.
# We just stick the source of these DLLs directly on the PATH.
import os;os.environ["PATH"]+=(';'+os.path.join(sitedir,"pywin32_system32"))

Or create a PYTHONPATH environment variables, and append the win32 and win32/lib path into it.

You could also add these two paths to Python in project temporarily?

import sys

The addition of paths is only valid for the time being.

Respondent: Drake Wu

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy