在使用PyCharm进行远程调试时遇到过如下错误。在断点触发后,想要直接执行语句,但在Evaluation Expression这个窗口遇到类似下面的错误,

ValueError: invalid literal for int() with base 10: '1 __py_debug_temp_var_2119182417'

在PyCharm的调试console里面会出现,

unexpected EOF while parsing (<string>, line 1

在待调试进程的输出中会出现,

Error while evaluating expression: ALL
Traceback (most recent call last):
  File "_pydevd_bundle/pydevd_cython.pyx", line 598, in _pydevd_bundle.pydevd_cython.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython.c:9763)
    val = eval(condition, new_frame.f_globals, new_frame.f_locals)
  File "<string>", line 1, in <module>
NameError: name 'ALL' is not defined
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\_pydevd_bundle\pydevd_process_net_command.py", line 360, in process_net_command
    cmd_id == CMD_EXEC_EXPRESSION, int(trim) == 1)
ValueError: invalid literal for int() with base 10: '1 __py_debug_temp_var_2119182417'

这个问题出现的原因是PyCharm内的Debug Server与被调试进程的Pydevd的版本不一致。版本不一致的可能有两个,

一是被调试进行没有使用与PyCharm版本匹配的pycharm-debug.egg。这个问题容易发现,在PyCharm调试console里面会提示说有版本不一致。基本功能没有问题,但是到了执行语句时就会出错。

另外一个可能的原因是机器环境上单独安装了pydevd,

可以试验一下,

pip install pydevd

在安装之后,再触发远程调试,进程如上操作。估计就会出现这个问题。解决的方法也很简单,移除pydevd即可,

pip uninstall pydevd