Search code examples
python-3.xwindowswindows-10mobaxterm

ModuleNotFoundError: No module named 'win32com'


Actually, I have the same problem as him:

No module named win32com

I have installed pywin32 but MobaXterm tells me "No module named win32com".enter image description here

However, I am able to run my program using IDLE with no error.

enter image description here

What's the problem?

Code:

import win32com.client
import sys, os
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut('C:/Users/Seaky/Desktop/CS 160.lnk')
os.chdir(shortcut.Targetpath)

What I am doing is that I am trying to do "cdlnk path" in the terminal using python code, where the path is a shortcut folder like the path above instead of a real path.

I used different code for running in the terminal and the IDLE but I only changed the path string from sys.argv[1] to the current one, which should not affect the result.


Solution

  • I have found out. The compiler of python installed in the MobaXterm doesn't have the pywin32 module.