0

I can't import pd from pandas because i have this error. I search on google but I didn't find the fix for this..

>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python37\lib\site-packages\pandas\__init__.py", line 23, in <module>
    from pandas.compat.numpy import *
  File "C:\Python37\lib\site-packages\pandas\compat\__init__.py", line 431, in <module>
    re_type = typing.re.Pattern
AttributeError: module 'typing' has no attribute 're'

1 Answers1

0

I think this is changing underneath us as Python's typing module matures, but in our case, the issue was that we did from Typing import re, and then later did something like:

def funct(some_re: re.Pattern):

The fix was dumb. Simply change your import to be from typing import Pattern and then do:

def funct(some_re: Pattern):

Bleh. Warts.

mlissner
  • 17,359
  • 18
  • 106
  • 169