Skip to main content
updating code after library removal/rename in python 3.12
Source Link

When I wanted to re-import the startup.py file after I made some edits, I used:

import imp, startup
# Use last 3 lines to reload script after saving edits
imp.reload(startup)
from startup import *
run_function()

This saved me the trouble of having to restart QGIS.

Since imp has been removed in python version 3.12, use importlib instead:

import importlib, startup
# Use last 3 lines to reload script after saving edits
importlib.reload(startup)
from startup import *
run_function()

When I wanted to re-import the startup.py file after I made some edits, I used:

import imp, startup
# Use last 3 lines to reload script after saving edits
imp.reload(startup)
from startup import *
run_function()

This saved me the trouble of having to restart QGIS.

When I wanted to re-import the startup.py file after I made some edits, I used:

import imp, startup
# Use last 3 lines to reload script after saving edits
imp.reload(startup)
from startup import *
run_function()

This saved me the trouble of having to restart QGIS.

Since imp has been removed in python version 3.12, use importlib instead:

import importlib, startup
# Use last 3 lines to reload script after saving edits
importlib.reload(startup)
from startup import *
run_function()
Source Link
Joseph
  • 76.3k
  • 7
  • 172
  • 286

When I wanted to re-import the startup.py file after I made some edits, I used:

import imp, startup
# Use last 3 lines to reload script after saving edits
imp.reload(startup)
from startup import *
run_function()

This saved me the trouble of having to restart QGIS.