Skip to content

Instantly share code, notes, and snippets.

@166MMX
Last active October 3, 2020 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 166MMX/f1372d3229bb13df7d0f4b96828d35ec to your computer and use it in GitHub Desktop.
Save 166MMX/f1372d3229bb13df7d0f4b96828d35ec to your computer and use it in GitHub Desktop.
PyCharm fix module name clash during debugger startup
from contextlib import contextmanager
@contextmanager
def bootstrap():
from os import environ
from sys import path as sys_path
roots = environ['IDE_PROJECT_ROOTS'].split(':')
pwd = environ['PWD']
try:
for root in roots:
while root in sys_path:
sys_path.remove(root)
while pwd in sys_path:
sys_path.remove(pwd)
yield None # satisfy contextmanager
finally:
for root in roots:
sys_path.insert(0, root)
sys_path.append(pwd)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 43, in <module>
from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PYCHARM, get_thread_id, get_current_thread_id, \
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py", line 216, in <module>
from _pydev_imps._pydev_saved_modules import thread
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_saved_modules.py", line 21, in <module>
import xmlrpc.client as xmlrpclib
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/xmlrpc/client.py", line 136, in <module>
import http.client
ModuleNotFoundError: No module named 'http.client'
with bootstrap():
# wrap _pydevd and pydevd import block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment