Pycharm上的Vagrant调试python/django

Dan*_*Duh 11 python django debugging pycharm

我正在尝试在Vagrant中调试Django项目.

我搜索了答案并阅读了有关Vagrant,使用Pycharm进行远程调试等所有可用文档.

我现在拥有的是完美的"运行"命令

ssh://vagrant@127.0.0.1:2222/home/vagrant/dev-projects/OP_3.0/bin/python2.7 -u
 /home/vagrant/dev-projects/3.0/online_platform/manage.py runserver 8000

0 errors found
April 06, 2014 - 02:32:40
Django version 1.6.2, using settings 'local_settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)

我可以从HOST访问它,一切都可以正常工作.
但是,当我尝试运行"调试"命令时,我有这个:

ssh://vagrant@127.0.0.1:2222/home/vagrant/dev-projects/OP_3.0/bin/python2.7 -u
 /home/vagrant/pydev/pydevd.py --multiproc --client '0.0.0.0' --port 34117 --file /home/vagrant/dev-projects/3.0/online_platform/manage.py runserver 8000

Traceback (most recent call last):
  File "/home/vagrant/pydev/pydevd_comm.py", line 310, in OnRun
    self.handleExcept()
  File "/home/vagrant/pydev/pydevd.py", line 1414, in handleExcept
    ReaderThread.handleExcept(self)
  File "/home/vagrant/pydev/pydevd_comm.py", line 329, in handleExcept
    GlobalDebuggerHolder.globalDbg.FinishDebuggingSession()
AttributeError: 'NoneType' object has no attribute 'FinishDebuggingSession'
Traceback (most recent call last):
  File "/home/vagrant/pydev/pydevd.py", line 1497, in <module>
    dispatcher.connect(host, port)
  File "/home/vagrant/pydev/pydevd.py", line 1400, in connect
    self.reader.run()
  File "/home/vagrant/pydev/pydevd_comm.py", line 252, in run
    self.OnRun()
  File "/home/vagrant/pydev/pydevd_comm.py", line 325, in OnRun
    self.handleExcept()
  File "/home/vagrant/pydev/pydevd.py", line 1414, in handleExcept
    ReaderThread.handleExcept(self)
  File "/home/vagrant/pydev/pydevd_comm.py", line 329, in handleExcept
    GlobalDebuggerHolder.globalDbg.FinishDebuggingSession()
AttributeError: 'NoneType' object has no attribute 'FinishDebuggingSession'

Process finished with exit code 1`
Run Code Online (Sandbox Code Playgroud)

任何真正的帮助,请...

das*_*s-g 3

如果你

  1. 让您的 PyCharm 项目配置了解项目的 vagrant box
  2. 设置一个远程解释器,其类型Vagrant引用 vagrant box 中正确的 python 可执行文件
  3. 使用该远程解释器作为项目的 python 解释器

那么您就不必ssh再自己为调试器命令行而烦恼了。只需告诉 PyCharm 您想要调试什么,就好像它是本地进程一样。(如果您还让 PyC​​harm 知道它正在处理 Django 项目,可能会更好。)