Reload script engine

Does anybody know how to reload the script engine?

I mean, I’d like to modify the external modules in the …python\lib\site-packages directory and then run my code again in the blender console (or in the text editor) with the applied changes. So far I have to quit blender in order to make this happening. Is there a smarter way to do this job? I also tried to “del” the module and “import” it again but nothing changed.

There’s another annoying behaviour of the text editor that I wasn’t able to find a solution at… Is it possible to avoid the editor to UNDO while I click CTRL-Z in the 3D viewport?

Let’s think at a mesh which will be modified by the running script.
Let’s suppose now that I want to add a few lines to the script and run it.
If I want to restore the original mesh after the script has finished I always loose the last changes to the script (even if I save before run it).

Does this behaviour depends on the state of the code (internal or not) and is possible to avoid the UNDO?

What I’m doing right now is to save the script, unlink it and open it again before running it :spin:.

[EDIT] Apparently I found a solution to one of my problems in the code snippets (chapter 11 - Multi-fiile packages) by Thomas Larsson:

“Fortunately, you don’t have to restart Blender to reload the files after each
modification. Hitting F8 on the keyboard reloads all activated add-ons into
Blender.”

Unfortunately hitting F8 after editing an addon didn’t result in what I hoped and the behaviour of the addon I modified remained unchanged. So I’m wondering what really happened when I pressed the F8 button and I’m still looking for answers to my old questions… :frowning:

Still looking for some answers… I found what it seemed to be a solution but didn’t work for me (look at the edited part at the top of this thread).

I was talking about Blender Python addons and your mod succesfully solved the problem, thanks.
Concerning the few tests I made it seems that everything works smooth and multi-file addons are correctly reloaded with the applied changes. The changes made to files in the … python / lib / site-packages directory still seem to be ignored instead and a Blender restart is necessary.
Thanks again guy, u’re great!