NameError: name 'reload' not defined

I am using python 3.2.2. When I write a simple program, I encounter a problem.

>>> reload(recommendations) Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> reload(recommendations) NameError: name 'reload' is not defined 

How should I do it?

+29
python
Apr 13 '12 at 14:30
source share
2 answers

You probably wanted importlib.reload() .

 from importlib import reload 

In Python 2.x, it was built-in , but in 3.x it was in the importlib module.

Note that using reload() outside the interpreter is not necessary at all, what were you trying to do here?

+75
Apr 13 2018-12-14T00:
source share

Updating @Gareth Latty's answer. imp was depreciated in Python 3.4. Now you want importlib.reload() .

 from importlib import reload 
+5
Jun 06 '17 at 16:38 on
source share



All Articles