Cannot start / debug Django manage.py from eclipse

Whenever I try to debug Django manage.py from Eclipse, I get:

 pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower) pydev debugger: starting Traceback (most recent call last): File "/proj/virtualenvs/testing/infocards/manage.py", line 15, in <module> execute_manager(settings) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/core/management/commands/runserver.py", line 67, in handle self.run(*args, **options) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/core/management/commands/runserver.py", line 76, in run autoreload.main(self.inner_run, args, options) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/utils/autoreload.py", line 131, in main reloader(main_func, args, kwargs) File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/utils/autoreload.py", line 104, in python_reloader reloader_thread() File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/utils/autoreload.py", line 83, in reloader_thread ensure_echo_on() File "/proj/virtualenvs/testing/lib/python2.6/site-packages/django/utils/autoreload.py", line 77, in ensure_echo_on attr_list = termios.tcgetattr(fd) termios.error: (22, 'Invalid argument') Validating models... 

Running python manage.py runserver from the command line is fine.

As a result of the search, I found that the termios.error: (22, 'Invalid argument') error is that python is trying to read from stdin but cannot from inside the Eclipse environment.

[Edit]: I forgot to mention that I am running PyDev and the latest version of Django version 1.3.

[Edit]: @Blake, @izhak. I am Eclipse I defined Python included in my virtualenv (/ proj / virtualenvs / testing, as you can see from the output). From the command line, I use the same version of Python that I activated virtualenv.

+4
source share
6 answers

It seems that the lack of --noreload is causing this effect. Weird

EDIT: At first, I thought this was the working directory of the project.

+3
source

Spend 3 hours figuring out this problem. The main culprit is the django 1.3 autoload.py file. Basically, Eclipse stdin is not a device type. The hack for this problem is to modify / your -path-to-django / util / autoreload.py like this:

 index e5a421e..1a4a1a1 100644 --- a/autoreload_bak.py +++ b/usr/local/lib/python2.6/dist-packages/django/utils/autoreload.py @@ -73,11 +73,12 @@ def code_changed(): def ensure_echo_on(): if termios: - fd = sys.stdin.fileno() - attr_list = termios.tcgetattr(fd) - if not attr_list[3] & termios.ECHO: - attr_list[3] |= termios.ECHO - termios.tcsetattr(fd, termios.TCSANOW, attr_list) + if sys.stdin.isatty(): + fd = sys.stdin.fileno() + attr_list = termios.tcgetattr(fd) + if not attr_list[3] & termios.ECHO: + attr_list[3] |= termios.ECHO + termios.tcsetattr(fd, termios.TCSANOW, attr_list) def reloader_thread(): ensure_echo_on() 

This should allow you to run runerver in Eclipse even without the -noreload option.

Note. You still need to apply this patch to get rid of the problem with the child / parent process, see here: How to enable Eclipse debugging features in a web application?

+2
source

I had the same error when I tried to just start the django program from Eclipse. If I right-click on the project and then select Django โ†’ Custom Command and "runningerver", it will fail. I finally found out that by clicking the Run button on the Eclipse toolbar, it will work. Even there, however, I found that this was not always the right thing. I am running the latest version of PyDev 2.0. Like you, run it every time from the command line outside of eclipse.

+1
source

Have you tried installing the PyDev plugin for Eclipse? It really makes it easier for Eclipse users to develop Python applications, and especially Django applications. Just create a new Django project and you will get a well-tuned environment and manage.py available for work from the project context menu.

0
source

Do you have multiple versions of Python on your system? If the version opened from the terminal is different from the version used by the PyDev interpreter, this may cause problems / differences in the working environment.

0
source

You can check Eclipse> Windows> Preferences> Pydev> Python for use in python versionu u. Give the exact version of python and use there.

0
source

Source: https://habr.com/ru/post/1346984/


All Articles