PyCharm 2026.2.0.1/Win 11: Debugging makepy.py

Hello again,

I must debug makepy.py - a tool used for Windows COM/ActiveX support, importing (registered) type libraries.
makepy.py is installed via pywin32.

How do I set up the project correctly - using a certain Python interpreter, not an virtual environment.

1. My Python interpreter is in folder:
MyPath\Python3147-32\python.exe

2. makepy.py here:
MyPath\Python3147-32\Lib\site-packages\win32com\client\makepy.py

When I run makepy.py with my current settings, I get a  
ModuleNotFoundError: No module named 'pythoncom'

3. pythoncom.py here:
MyPath\Python3147-32\Lib\site-packages\pythoncom.py


I'm overwhelemd from all the settings in different places!

Any hints are highly appreciated!
StormFennec

0

Hi StormFennec

ModuleNotFoundError: No module named 'pythoncom' is a path problem, not a pywin32 problem. The Python process PyCharm started never saw MyPath\Python3147-32\Lib\site-packages, which means it is not the same Python as MyPath\Python3147-32\python.exe. A half-installed pywin32 would fail with a different message, ImportError: No system module 'pythoncom'.

Point PyCharm at that interpreter:

1) Open Settings | Python | Interpreter and use the Add Interpreter link
2) Choose Add Local Interpreter, then Python as the environment type
3) Browse to MyPath\Python3147-32\python.exe and confirm

Selecting an existing python.exe this way creates no virtual environment, which is what a 32-bit COM setup normally wants.

Run configurations follow the project interpreter unless told otherwise, so those three steps are usually enough. The run configuration also has its own Python Interpreter field, for the case where only that one configuration should change. The field only lists interpreters that were already added, so step 1 comes first regardless.

The same dialog has a Script path/Module name selector. Switching it to Module name and entering win32com.client.makepy is the form pywin32 documents, and it keeps the run target off a file inside site-packages

SUPPORT-A-1722 explains why an installed package belongs to one interpreter and stays invisible to the others. SUPPORT-A-4135 covers reusing one environment across projects, which is the usual answer to interpreter settings living in several places.

0

请先登录再写评论。