Python Integration Tutorial Attribute Error

« Go Back

Information

 
QuestionHow do I fix the following error: AttributeError: module 'comtypes.gen.AgUiApplicationLib' has no attribute '_IAgUiApplication'
Answer

This error occurs when the comtypes folder is generated improperly/incompletely during the initial generation.

Even though the contents are incorrect, the file name is correct so Python thinks the file is fine/doesn't need fixing. The way to fix the issue is to delete the entire "gen" folder which is found here:
C:\Users\YOUR_USERNAME\AppData\Local\Continuum\anaconda3\Lib\site-packages\comtypes

Note: This path assumes the user is using the Anaconda environment.

Then a user must run the following code in the console:
 

from win32api import GetSystemMetrics
import comtypes
from comtypes.client import CreateObject
uiApplication = CreateObject("STK11.Application")

This will regenerate the folders and files necessary properly and will fix the issue.

Please see the "Troubleshooting Your STK and Python Integration" FAQ for more information and other options to get your Python working with STK.
TitlePython Integration Tutorial Attribute Error
URL NamePython-Integration-Tutorial-Common-Error

Related Files