Reloading module giving NameError: name ‘reload’ is not defined

reload is a builtin in Python 2, but not in Python 3, so the error you’re seeing is expected.

If you truly must reload a module in Python 3, you should use either:

  • importlib.reload for Python 3.4 and above
  • imp.reload for Python 3.0 to 3.3 (deprecated since Python 3.4 in favour of importlib)

Leave a Comment