22

I have been fooling around for about a month with python now and something is bothering me. I use the python(x,y) toolkit, which comes with the neat Spyder IDE. My question concerns the UMD (User module deleter) of Spyder.

I found this graphics module on the internet, which helps one to do some simple graphic stuff in a python script (as far as I understand).

It is not like i'm stuck, but when I execute the folowing code:

import pylab as p
import graphics as g

window = g.GraphWin("tryout", 600, 600)
window.close()
print p.sqrt(4)

The output is:

>>>runfile(r'C:\some\folders\tryout.py', wdir=r'C:\some\folders')
>>>UMD has deleted: graphics
>>>2.0

line 1 is obviously o.k. and so is line 3, but I don't get line 2. Also, the provoked window flashes in and out of the screen, as it should. Line 2 doesn't seem to do any harm, and i can perfectly rerun the file as many times as I wan't, but I want to know where it is comming from.

AFAIK UMD forces the interpreter to reload a module everytime a script is run. Does the displayed message mean that 'it' has deleted the references to the module, because it isn't used anymore, or is it something else? Or does it mean something is wrong, and will it 'hurt' my code should I add more afterwards?

Note: first question, so please comment the crap out of it to help me improve my asking skills.

EDIT: i tried shifting around the test line print p.sqrt(4), and found out that it doesn't matter where I put it. If its the first line after importing the modules, it still raisses the message before showing sqrt(4)

Community
  • 1
  • 1
Kraay89
  • 919
  • 1
  • 7
  • 19

1 Answers1

44

Short Answer:

Perhaps deleted is not the best word in the message you mention. It should be reloaded, which is what UMD is really doing and because is way less confusing. I'll fill an issue for this in our issue tracker.

Long answer:

UMD reloads not only your script but also all the local modules it depends on. By local I mean modules outside your Python installation and over which you have writing permissions.

The idea is that next to your script, perhaps you have developed a library of auxiliary functions to go with it. So you most probably want to reload that library too, so that any changes to it are reflected at run time.

I know this is not your case, so if you want to remove that message, you can go to:

Tools > Preferences > Console > Advanced settings > User Module Deleter

and deactivate the option

Show reloaded modules list

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • Useful, it prints a very long list when using Mayavi for example, since this "Show reloaded modules list" is more for debugging, shouldn't it be disabled by default? – dashesy Mar 10 '13 at 21:20
  • 2
    I don't think it's for debugging; it's more about informing the user what modules have been reloaded before the next execution. In your case, since I guess you have Mayavi installed locally, you can deactivate the message for it adding it to the list of excluded modules. – Carlos Cordoba Mar 11 '13 at 01:24
  • 1
    This caused a problem with developing software for ROS. I believe UMD affected the path to ROS environment variables as I would be able to run code once, but not a second time, as the modules of interest could not be found. Deactivated UMD stopped this annoying occurrence. – trianta2 May 23 '14 at 16:56
  • Does that means disable it will get better performance every time run my script? – lucky1928 Nov 24 '14 at 19:36
  • @Beetlej Nop, the effect on performance is minimal. It's better for you to leave it so that changes you do on your code are reflected at run time. – Carlos Cordoba Nov 25 '14 at 01:23
  • 2
    It's awesome when the answer is authoritative in this manner. It's also pretty neat that looking at the same instructions a few years later, it's called UMR, for reloader, and that the change is so thoroughly done. For newer versions of spyder, the menu sequence is *Tools > Preferences > Python Interpreter > Advanced Settings > User Module Reloader (UMR)*. – Mad Physicist Sep 19 '19 at 19:06