Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant debugging python/django on Pycharm

I'm trying to debug Django project inside Vagrant.

I did searched for the answers and read all available documentations about Vagrant, Remote debugging with Pycharm and more.

What I do have now is perfectly working "Run" command

ssh://[email protected]: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.

I can access to it from HOST, and everything works just as suposed to.
But when I'm trying run a "Debug" command I have this:

ssh://[email protected]: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`

Any real help, please...

like image 928
DanDuh Avatar asked Apr 06 '14 09:04

DanDuh


People also ask

Can Django be used in PyCharm?

PyCharm supports the latest Django versions. The corresponding Python versions depend on Django.

How do I add vagrant to PyCharm?

Press Ctrl+Alt+S to open the IDE settings and select Plugins. Install the Vagrant plugin.


1 Answers

If you

  1. Let your PyCharm project configuration know about the project's vagrant box
  2. Set up a remote interpreter of type Vagrant referencing the right python executable within the vagrant box
  3. Use that remote interpreter as your project's python interpreter

then you shouldn't have to fuss around with ssh and with debugger command lines yourself anymore. Just tell PyCharm what you want to debug as if it were a local process. (Might work even better if you also let PyCharm know that it's dealing with a Django project.)

like image 123
das-g Avatar answered Sep 24 '22 05:09

das-g