pythonpython-importcomtypes

ImportError: No module named comtypes in Python 3.6


I'm using Python 3.6. I have installed the module comtypes via the command

python -m pip install comtypes
Requirement already satisfied: comtypes in c:\users\singtech\appdata\local\programs\python\python36-32\lib\site-packages

But I am still getting the import error for comtypes from my script:

import comtypes.client as cc
import comtypes

mylib = cc.GetModule("d:\\path\\to\\mylib.dll")
print(mylib)

When I run the script, it produces the following error :

Traceback (most recent call last):
  File "D:\python-apps\aos.py", line 1, in <module>
    import comtypes.client as cc
ImportError: No module named 'comtypes'

Solution

  • I run the script in the Python beginner IDE Thonny. It uses a different interpreter. When I setup the correct interpreter path in IDE's options, the import error gone away.

    enter image description here