ImportError: cannot import name 'COMError' from '_ctypes'

1.7k Views Asked by At

I got the error like :

ImportError Traceback (most recent call last) in ----> 1 import pyeviews as pye

1 frames /usr/local/lib/python3.9/dist-packages/comtypes/init.py in 26 27 from ctypes import * ---> 28 from _ctypes import COMError 29 from comtypes import patcher 30

ImportError: cannot import name 'COMError' from '_ctypes' (/usr/lib/python3.9/lib-dynload/_ctypes.cpython-39-x86_64-linux-gnu.so)

I am trying to install pypeviews package in google colab,:

!pyp install pypeviews

and I got:

Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ Requirement already satisfied: pyeviews in /usr/local/lib/python3.9/dist-packages (1.0.5) Requirement already satisfied: comtypes in /usr/local/lib/python3.9/dist-packages (from pyeviews) (1.1.14) Requirement already satisfied: pandas in /usr/local/lib/python3.9/dist-packages (from pyeviews) (1.3.5) Requirement already satisfied: numpy in /usr/local/lib/python3.9/dist-packages (from pyeviews) (1.22.4) Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.9/dist-packages (from pandas->pyeviews) (2022.7.1) Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.9/dist-packages (from pandas->pyeviews) (2.8.2) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.9/dist-packages (from python-dateutil>=2.7.3->pandas->pyeviews) (1.15.0)

It seems like I have installed. But, when I try to import this package, I got:

ImportError: cannot import name 'COMError' from '_ctypes' (/usr/lib/python3.9/lib-dynload/_ctypes.cpython-39-x86_64-linux-gnu.so)

and here is my import code:

import pyeviews as pye

I do not know why, and how can I fix this error?

1

There are 1 best solutions below

0
amitesh863 On

The library uses COM to transfer data between Python and EViews as mentioned on their git page.

COMTypes are supported only for Windows and isn't available for Linux. Colab has linux-based OS as their default OS.

https://pypi.python.org/pypi/comtypes

comtypes allows to define, call, and implement custom and dispatch-based COM interfaces in pure Python. It works on Windows, 64-bit Windows, and Windows CE.