使用PyCharm调试扭曲的应用程序

时间:2015-01-31 16:19:52

标签: python debugging twisted pycharm

我正在花几个小时试图配置PyCharm来调试我的应用程序。我一直在寻找解决方案,但扭曲似乎并不那么受欢迎,而且支撑力度很弱。下面我把我得到的错误日志。

/usr/local/bin/python3.4m -u /Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py 57276 57277 /usr/bin/twistd -y /Users/artur/projs/private/elanga-web/start_app.tac
Running /usr/bin/twistd
PyDev console: starting.
Traceback (most recent call last):
  File "/usr/bin/twistd", line 7, in <module>
    import _preamble
ImportError: No module named '_preamble'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py", line 68, in <module>
    globals = run_file(file, None, None)
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_run_in_console.py", line 28, in run_file
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc) 
  File "/usr/bin/twistd", line 9, in <module>
    sys.exc_clear()
AttributeError: 'module' object has no attribute 'exc_clear'

Process finished with exit code 1
Couldn't connect to console process.

我将很感激为什么没有像_preamble

这样的模块的答案

1 个答案:

答案 0 :(得分:6)

在OS X上,/usr/bin/twistd是安装在系统python中的Twisted版本。这不是python 3.4。您看到的症状不是缺少的_preamble模块(实际上应该安装,这就是为什么周围有except块的原因import捕获异常)但是你已经在一些随机的python 2程序中指出了python 3.4。

如果你想运行python 3.4,你需要创建一个安装了Twisted的python 3环境。请记住,并非所有Twisted都已移植,因此只有一部分API可供您使用。其中一个没有移植到python 3的东西是twistd命令行,所以还没有办法用python 3运行twistd