Pycharm profession error running debugger 'thread' has no attribute 'start_new_thread'
Recently pycharm professional version (2020.2.3) debugger will not launch with this error:
..
patch_thread_modules
patch_thread_module(t)
File "/Users/p2721905/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/202.7660.27/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_monkey.py", line 817, in patch_thread_module
_original_start_new_thread = thread_module._original_start_new_thread = thread_module.start_new_thread
AttributeError: module 'thread' has no attribute 'start_new_thread'
I am running on mac (macOS Catalina version 10.15.7). I have downgraded, reinstalled and still no luck. At this point i cannot debug anything. I have tried various versions on python, from 3.7.1 to 3.8.x with no luck.
Thanks.
请先登录再写评论。
Hi,
Might be issues with helpers. Could you please reinstall while also deleting the associated [PyCharm 2020.2 directories](https://www.jetbrains.com/help/pycharm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html) ?
Hello, I ran into the same error on Ubuntu machine, tried reinstall and deleting directories, but still the same error.
I added a line "print(type(thread_module), dir(thread_module))" at pydev_monkey.py:810 and see:
<class 'module'> ['LOGGER', 'PARSER', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'agent', 'argparse', 'environment', 'get_cluster_def', 'logging', 'main', 'multiprocessing', 'os', 'run_worker', 'signal', 'sys', 'tf', 'time']
whatever this 'module' is, it's not a threading.Thread. So I modified method
def patch_thread_modules():
for t in threading_modules_to_patch:
if isinstance(t, threading.Thread):
patch_thread_module(t)
else:
print(type(t), dir(t))
It seems to fix the problem. And prints
<class 'module'> ['LOGGER', 'PARSER', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'agent', 'argparse', 'environment', 'get_cluster_def', 'logging', 'main', 'multiprocessing', 'os', 'run_worker', 'signal', 'sys', 'tf', 'time']
<class 'module'> ['Barrier', 'BoundedSemaphore', 'BrokenBarrierError', 'Condition', 'Event', 'ExceptHookArgs', 'Lock', 'RLock', 'Semaphore', 'TIMEOUT_MAX', 'Thread', 'ThreadError', 'Timer', 'WeakSet', '_CRLock', '_DummyThread', '_HAVE_THREAD_NATIVE_ID', '_MainThread', '_PyRLock', '_RLock', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_active', '_active_limbo_lock', '_after_fork', '_allocate_lock', '_count', '_counter', '_dangling', '_deque', '_enumerate', '_islice', '_limbo', '_main_thread', '_make_invoke_excepthook', '_newname', '_os', '_profile_hook', '_set_sentinel', '_shutdown', '_shutdown_locks', '_shutdown_locks_lock', '_start_new_thread', '_sys', '_time', '_trace_hook', 'activeCount', 'active_count', 'currentThread', 'current_thread', 'enumerate', 'excepthook', 'get_ident', 'get_native_id', 'local', 'main_thread', 'setprofile', 'settrace', 'stack_size']
@Sevenseaswander
Does it happen with any code?
What PyCharm version do you use?
I had the same issue
the problem was:
one of the files in the project i wanted to debug was called: thread.py
weird things happen when using reserved words
Thanks Yarden for coming back to update this thread. I had a file named thread.py in my working directory also, removing it fixed it.
Thank Yarden. It's fixed
I'm experiencing this problem with PyCharm 2022.3.3
I'm trying to debug a Django project with a runserver and there are no files in my project called thread.py
The fix from Elsey works so far and this is some relevant output....
Would you consider submitting a bug report to https://youtrack.jetbrains.com with the following information?
- Your PyCharm version
- Your exact Python version
- Is the issue code-specific, i.e. is it reproducible in a new minimal project?
- Is the issue reproducible with another Python interpreter, e.g. using another version?
I've got same error but I can fix with removing "thread.py" from my directory.
Try to do
pip uninstall thread