首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ModuleNotFoundError:没有名为“autoreload”的模块

ModuleNotFoundError:没有名为“autoreload”的模块
EN

Stack Overflow用户
提问于 2017-12-01 00:01:00
回答 2查看 4.8K关注 0票数 16

我在带有python3内核的jupyter笔记本上运行了以下卷积神经网络教程中的代码,得到了ModuleNotFoundError:没有名为‘autoreload’的模块;

代码语言:javascript
运行
复制
import numpy as np
import h5py          
import matplotlib.pyplot as plt

%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'

%load_ext autoreload   
%autoreload 2          
np.random.seed(1)

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-3d0ea63c7843> in <module>()
      8 plt.rcParams['image.cmap'] = 'gray'
      9 
---> 10 get_ipython().magic('load_ext autoreload   # reload modules before executing user code')
     11 get_ipython().magic('autoreload 2          # Reload all modules (except those excluded by %aimport)')
     12 

/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
   2156         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2157         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158         return self.run_line_magic(magic_name, magic_arg_s)
   2159 
   2160     #-------------------------------------------------------------------------

/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
   2077                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2078             with self.builtin_trap:
-> 2079                 result = fn(*args,**kwargs)
   2080             return result
   2081 

<decorator-gen-62> in load_ext(self, module_str)

/opt/conda/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

/opt/conda/lib/python3.6/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str)
     35         if not module_str:
     36             raise UsageError('Missing module name.')
---> 37         res = self.shell.extension_manager.load_extension(module_str)
     38 
     39         if res == 'already loaded':

/opt/conda/lib/python3.6/site-packages/IPython/core/extensions.py in load_extension(self, module_str)
     81             if module_str not in sys.modules:
     82                 with prepended_to_syspath(self.ipython_extension_dir):
---> 83                     __import__(module_str)
     84             mod = sys.modules[module_str]
     85             if self._call_load_ipython_extension(mod):

ModuleNotFoundError: No module named 'autoreload'   

我只是在这个问题上找不到任何解决方案。我应该如何修复这个错误?

EN

回答 2

Stack Overflow用户

发布于 2018-11-25 23:41:45

模块自动加载属于库IPython,该库在Jupyter上后台运行。

同样的错误也发生在我身上,它是由于空格引起的,请参见:

因此,确保命令的末尾没有空格!

票数 22
EN

Stack Overflow用户

发布于 2020-06-17 04:41:26

我遇到了同样的错误,因为我在魔术命令之后有一个注释:

不好:

代码语言:javascript
运行
复制
%load_ext autoreload # this comment should be removed

好:

代码语言:javascript
运行
复制
%load_ext autoreload
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47577596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档