question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error Importing Module

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
azgordonjrcommented, 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

0reactions
mewforestcommented, Jun 21, 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

Wow! Thanks! Now it’s working!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python import module error - Stack Overflow
I have a problem in import of modules in my project. I was creating tests and I cant import my main to test...
Read more >
Python Import Error (ModuleNotFoundError) - Finxter
Python's ImportError ( ModuleNotFoundError ) indicates that you tried to import a module that Python doesn't find. It can usually be eliminated by...
Read more >
ModuleNotFoundError: no module named Python Error [Fixed]
For resolving an imported module, Python checks places like the inbuilt library, installed modules, and modules in the current project. If it's ...
Read more >
Resolve "Unable to import module" errors from Python ...
I receive an "Unable to import module" error when I try to run my AWS Lambda code in Python. How do I resolve...
Read more >
How do I resolve the "Unable to import module" error I receive ...
... Knowledge Center article with this video: https://aws.amazon.com/premiumsupport/knowledge-center/lambda- import - module - error -python/0...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found