Getting a strange python error when running a simple django script in Eclipse, which is not happening in the console

I am running a basic script that configures the django environment itself to allow me to test the django ORM functions without having to implement web pages. Then the script imports one of the types defined in my models. This error does not occur when I run this script from iPython, only from eclipse. Simply executing this import raises a strange exception, for example the following:

Exception AttributeError: "'NoneType' object has no attribute 'print_exc'" in <bound method Signal._remove_receiver of <django.dispatch.dispatcher.Signal object at 0x026802B0>> ignored 

My script looks like this:

 from django.core.management import setup_environ import settings setup_environ(settings) from stats.models import Person for p in Person.objects.all(): print p.Name 
+4
source share
5 answers

After importing an existing Django project into Eclipse, I had the same AttributeError attribute

I just deleted the * .pyc files ... and it works ...!?

  • right click on the project -> pyDev -> remove * .pyc, * .pyo, ...
+3
source

After some reasonable Google search, I would say that Eclipse is causing the problem and that it is difficult to track. print_exc is a function in the Python trace module. Eclipse may try to show you tracing, losing failures, and using the result in the process.

I think that a reasonable workaround would be to continue working on this script in a tool that does not present you with incomprehensible errors. You may find the actual (correctable) error in the code, or you will find that Eclipse raised a false alarm due to an error in its integration with Python.

If at this point you do not know if there are problems with your code, adding some tests may be useful.

+2
source

Is it possible that eclipse is using a different version of the python interpreter?

0
source

Could you provide more detailed information, for example, the Person model.

Not seeing that I assume the model attribute should be lowercase (e.g. p.name)

0
source

As far as I can see, you have no problem importing your modules. Try this to see if everything you need is ready. That probably wouldn't be the cause of your problem, but you'd better check it out too.

iPuthon automatically imports the django system path, so you need it at your fingertips.

 import sys sys.path 

check this to see if you need everything when you run it from eclipse, fiff with ipython result ...

0
source

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


All Articles