简体   繁体   English

Pycharm Debug 模式语法错误

[英]Pycharm Debug mode syntax error

all of a sudden when running PyCharm Community edition i've started to get this syntax error when running debug mode.在运行 PyCharm 社区版时,突然间我开始在运行调试模式时遇到此语法错误。 I tried reinstalling PyCharm but had no luck with the error.我尝试重新安装 PyCharm,但没有遇到错误。 Anyone see this before?有谁见过这个吗?

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 26, in <module>
    from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info.py", line 19, in <module>
    from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo  # @UnusedImport
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info_regular.py", line 5, in <module>
    from _pydevd_bundle.pydevd_frame import PyDBFrame
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_frame.py", line 10, in <module>
    from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_breakpoints.py", line 15, in <module>
    from _pydevd_bundle.pydevd_comm import get_global_debugger
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 75, in <module>
    import pydevconsole
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py", line 10, in <module>
    from _pydevd_bundle.pydevconsole_code_for_ironpython import InteractiveConsole
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevconsole_code_for_ironpython.py", line 105
    except SyntaxError, err:
                      ^
SyntaxError: invalid syntax

If you don't care about any project specific configurations or run configurations:如果您不关心任何项目特定的配置或运行配置:

  1. quit pycharm退出pycharm
  2. delete .idea folder in your project folder删除项目文件夹中的.idea文件夹
  3. start pycharm启动pycharm

I've used this method as a quick fix solution when I encountered this issue late last night.昨晚深夜遇到此问题时,我已将此方法用作快速修复解决方案。 But, the very nature of this solution indicates that this issue is caused by some corruption in the .idea folder.但是,此解决方案的本质表明此问题是由.idea文件夹中的某些损坏引起的。 Were I to encounter this problem again, I would suggest a different approach:如果我再次遇到这个问题,我会建议一种不同的方法:

  1. first, try to search for the error text in the files in the .idea folder首先,尝试在.idea文件夹中的文件中搜索错误文本
  2. if the previous step fails:如果上一步失败:
    1. quit pycharm退出pycharm
    2. move the .idea folder inside the project folder to a safe location将项目文件夹内的.idea文件夹移动到安全位置
    3. start pycharm to create a fresh .idea folder and quit it again启动 pycharm 创建一个新的.idea文件夹并再次退出
    4. preform a 3-way merge between the old and the new .idea folders在新旧.idea文件夹之间进行三向合并
    5. start pycharm启动pycharm

If you have __init__.py in your current path, delete it.如果当前路径中有__init__.py ,请将其删除。 Or if your file name is code.py , rename to something else.或者,如果您的文件名是code.py ,请重命名为其他名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM