Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: Cannot Import 'COMError' from '_ctypes' in comtypes Library #479

Closed
BasilcM opened this issue May 16, 2023 · 2 comments
Closed
Labels
shared_info use cases, tips and troubleshoots wontfix This will not be worked on

Comments

@BasilcM
Copy link

BasilcM commented May 16, 2023

I encountered an issue while working with the comtypes library in a Python 3.11 environment. The error occurs when trying to import the COMError class from the _ctypes module. Here are the details of the error message:

    import comtypes.client  # Importing comtypes.client will make the gen subpackage
    try:
        from comtypes.gen import SpeechLib  # comtypes

File ~/Documents/Jupyter Notebook/Speech/speechrec/lib/python3.11/site-packages/comtypes/__init__.py:28
    logger.addHandler(NullHandler())
    from ctypes import *
---> from _ctypes import COMError
    from comtypes import patcher
    def _check_version(actual, tlib_cached_mtime=None):

ImportError: cannot import name 'COMError' from '_ctypes' (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_ctypes.cpython-311-darwin.so)

Getting an ImportError when importing the COMError class from _ctypes.

Additional Information:

  • Python version: 3.11
  • Operating system: macOS
  • Python environment: Jupyter Notebook

Possible Causes and Solutions:

  1. Compatibility Issue: It's possible that the current version of comtypes is not fully compatible with Python 3.11. I would recommend checking the comtypes documentation or GitHub repository for any known compatibility issues or updates related to Python 3.11. Additionally, try installing an older version of comtypes that is known to work with Python 3.11.
  2. Installation Issue: The error might be caused by an incomplete or incorrect installation of comtypes. Try reinstalling the library using the command: pip install --force-reinstall comtypes.
  3. Dependency Issue: It's possible that there is a conflict or missing dependency related to the _ctypes module. Ensure that all the necessary dependencies are installed correctly, and there are no conflicting versions of _ctypes or related modules.

Please note that these are general suggestions, and it's recommended to consult the comtypes documentation or seek assistance from the library maintainers for more specific guidance.

@junkmd
Copy link
Collaborator

junkmd commented May 17, 2023

This is why comtypes did not work in your environment.

Therefore, comtypes would not work in the macOS env in even Python<3.11.

@junkmd junkmd added the shared_info use cases, tips and troubleshoots label May 17, 2023
@junkmd
Copy link
Collaborator

junkmd commented May 17, 2023

When the drop_py2 version including #423 is released, this error will be a little easier to understand.

@junkmd junkmd added the wontfix This will not be worked on label May 19, 2023
@junkmd junkmd closed this as completed May 19, 2023
@junkmd junkmd reopened this May 19, 2023
@junkmd junkmd closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shared_info use cases, tips and troubleshoots wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants