Spyder自动导入子模块
Spyder automatic import of submodules
这段代码在我拥有的所有 Python 环境中都失败了,但在 Spyder 中没有:
import scipy
print(scipy.integrate.cumtrapz([1, 2, 3]))
在大多数环境中你会得到
AttributeError: module 'scipy' has no attribute 'integrate'
除非你 import scipy.integrate
导入了子模块,但不知何故,如果你使用 "Execute in current Python or IPython console" 运行 配置,在 Spyder 中这段代码 运行s 没有错误。如果您使用 "Execute in a new dedicated Python console",它会失败。显然 Spyder 正在做一些事情来自动导入子模块,但我找不到任何地方记录这种行为。
问题 Spyder 在做什么,它在哪里记录以及如何关闭它。
环境:Anaconda 3 (4.3.0)、Spyder 3.1.2、Python3.5
您可以从 IPython 控制台切换到 Python 控制台(那里是不同的选项卡)。问题是 IPython 在不同的模式下(即 "matplotlib" 模式)加载了很多东西,而这个东西加载了很多东西。基本没法控制。
然而,当然有一些方法可以修改 Tools -> Preferences -> IPython console
下的 IPython 启动,但我不确定您是否可以禁用那里的 SciPy
导入。
这段代码在我拥有的所有 Python 环境中都失败了,但在 Spyder 中没有:
import scipy
print(scipy.integrate.cumtrapz([1, 2, 3]))
在大多数环境中你会得到
AttributeError: module 'scipy' has no attribute 'integrate'
除非你 import scipy.integrate
导入了子模块,但不知何故,如果你使用 "Execute in current Python or IPython console" 运行 配置,在 Spyder 中这段代码 运行s 没有错误。如果您使用 "Execute in a new dedicated Python console",它会失败。显然 Spyder 正在做一些事情来自动导入子模块,但我找不到任何地方记录这种行为。
问题 Spyder 在做什么,它在哪里记录以及如何关闭它。
环境:Anaconda 3 (4.3.0)、Spyder 3.1.2、Python3.5
您可以从 IPython 控制台切换到 Python 控制台(那里是不同的选项卡)。问题是 IPython 在不同的模式下(即 "matplotlib" 模式)加载了很多东西,而这个东西加载了很多东西。基本没法控制。
然而,当然有一些方法可以修改 Tools -> Preferences -> IPython console
下的 IPython 启动,但我不确定您是否可以禁用那里的 SciPy
导入。