Last active
October 3, 2020 08:55
-
-
Save 166MMX/f1372d3229bb13df7d0f4b96828d35ec to your computer and use it in GitHub Desktop.
PyCharm fix module name clash during debugger startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected]/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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