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

Error Importing Module #158

Open
pyrometheous opened this issue Jul 7, 2021 · 5 comments
Open

Error Importing Module #158

pyrometheous opened this issue Jul 7, 2021 · 5 comments

Comments

@pyrometheous
Copy link

pyrometheous commented Jul 7, 2021

I'm using PyCharm 2021.1.1 (Community Edition) with Python 3.9 on Windows 10 Version 20H2

When I try to import this module I get the following:

Traceback (most recent call last):
  File "C:\\Users\....\AppData\Local\Programs\Python\Python39\lib\sre_parse.py", line 1039, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\s'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\....\PycharmProjects\ProjectFolder\script_name.py", line 8, in <module>
    import pythonwhois
  File "C:\Users\....\PycharmProjects\ProjectFolder\venv\lib\site-packages\pythonwhois\__init__.py", line 1, in <module>
    from . import net, parse
  File "C:\Users\....\PycharmProjects\ProjectFolder\venv\lib\site-packages\pythonwhois\parse.py", line 359, in <module>
    registrant_regexes = [preprocess_regex(regex) for regex in registrant_regexes]
  File "C:\Users\....\PycharmProjects\ProjectFolder\venv\lib\site-packages\pythonwhois\parse.py", line 359, in <listcomp>
    registrant_regexes = [preprocess_regex(regex) for regex in registrant_regexes]
  File "C:\Users\....\PycharmProjects\ProjectFolder\venv\lib\site-packages\pythonwhois\parse.py", line 205, in preprocess_regex
    regex = re.sub(r"\\s\*\(\?P<([^>]+)>\.\+\)", r"\s*(?P<\1>\S.*)", regex)
  File "C:\Users\....\AppData\Local\Programs\Python\Python39\lib\re.py", line 210, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "C:\Users\....\AppData\Local\Programs\Python\Python39\lib\re.py", line 327, in _subx
    template = _compile_repl(template, pattern)
  File "C:\Users\....\AppData\Local\Programs\Python\Python39\lib\re.py", line 318, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "C:\Users\....\AppData\Local\Programs\Python\Python39\lib\sre_parse.py", line 1042, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \s at position 0
@fpalop73
Copy link

Hi!
Same problem. Any solution?
Thanks

@fpalop73
Copy link

sorry, it was already solved.

@lebonMIA
Copy link

lebonMIA commented Nov 4, 2021

Hi @fpalop73 I have the same problem, would you mind sharing the solution ? thanks

@gordonnoah
Copy link

gordonnoah commented Jan 15, 2022

@lebonMIA check out this PR "Fix to get regex to work on python > 3.6". If you are running python 3 you might need to edit the preprocess_regex fun in parse.py, it worked for me

@mewforest
Copy link

@lebonMIA check out this PR "Fix to get regex to work on python > 3.6". If you are running python 3 you might need to edit the preprocess_regex fun in parse.py, it worked for me

Wow! Thanks! Now it's working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants