`local variable 'traceback' referenced before assignment when using run console over ssh

When attempting to run a file via an ssh interpreter, I get the following error:

```

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/morrill/Documents/.pycharm_helpers/pydev/_pydev_bundle/pydev_code_executor.py", line 108, in add_exec
more, exception_occurred = self.do_add_exec(code_fragment)
File "/home/morrill/Documents/.pycharm_helpers/pydev/pydevconsole.py", line 90, in do_add_exec
command.run()
File "/home/morrill/Documents/.pycharm_helpers/pydev/_pydev_bundle/pydev_console_types.py", line 35, in run
self.more = self.interpreter.runsource(text, '<input>', symbol)
File "/scratch/morrill/github/marker_disease_associations/env/lib/python3.9/code.py", line 74, in runsource
self.runcode(code)
File "/scratch/morrill/github/marker_disease_associations/env/lib/python3.9/code.py", line 94, in runcode
self.showtraceback()
File "/scratch/morrill/github/marker_disease_associations/env/lib/python3.9/code.py", line 148, in showtraceback
sys.excepthook(ei[0], ei[1], last_tb)
File "/home/morrill/Documents/.pycharm_helpers/pydev/pydevconsole.py", line 112, in info
traceback.print_exception(type, value, tb)
NameError: name 'traceback' is not defined
Traceback (most recent call last):
File "/home/morrill/Documents/.pycharm_helpers/pydev/pydevconsole.py", line 284, in process_exec_queue
interpreter.add_exec(code_fragment)
File "/home/morrill/Documents/.pycharm_helpers/pydev/_pydev_bundle/pydev_code_executor.py", line 132, in add_exec
return more, exception_occurred
UnboundLocalError: local variable 'exception_occurred' referenced before assignment
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/morrill/Documents/.pycharm_helpers/pydev/pydevconsole.py", line 511, in <module>
pydevconsole.start_server(port)
File "/home/morrill/Documents/.pycharm_helpers/pydev/pydevconsole.py", line 407, in start_server
process_exec_queue(interpreter)
File "/home/morrill/Documents/.pycharm_helpers/pydev/pydevconsole.py", line 292, in process_exec_queue
traceback.print_exception(type, value, tb, file=sys.__stderr__)
UnboundLocalError: local variable 'traceback' referenced before assignment

```

0
1 comment

Hello, 

 

this is a known regression unfortunately, https://youtrack.jetbrains.com/issue/PY-51691. The fix is expected in the next minor update. 

Possible workaround is presented here  https://youtrack.jetbrains.com/issue/PY-51691#focus=Comments-27-5623909.0-0 

Replace <PyCharm_installation_folder>/plugins/python/helpers/pydev/pydevconsole.py with the attached file and

ssh to the server and remove /home/morrill/Documents/.pycharm_helpers/, restart PyCharm, it will reupload the helpers

 

Should you have any questions please let me know. 

0

Please sign in to leave a comment.