chthonicdaemon
chthonicdaemon

Reputation: 19810

Spyder automatic import of submodules

This code fails in all the Python environments I have, but not in Spyder:

import scipy
print(scipy.integrate.cumtrapz([1, 2, 3]))

In most environments you would get

AttributeError: module 'scipy' has no attribute 'integrate'

unless you did import scipy.integrate to get the submodule imported, but somehow, in Spyder this code runs without error if you use the "Execute in current Python or IPython console" run configuration. It fails if you use "Execute in a new dedicated Python console". Clearly Spyder is doing something to import the submodule automatically, but I cannot find this behaviour documented anywhere.

The questions are what is Spyder doing, where is this documented and how can I turn it off.

Environment: Anaconda 3 (4.3.0), Spyder 3.1.2, Python 3.5

Upvotes: 3

Views: 1631

Answers (1)

MSeifert
MSeifert

Reputation: 152725

You can switch from the IPython console to the Python console (it's a different tab there). The problem is that IPython in different modes (i.e. "matplotlib" mode) loads a lot of stuff and this stuff loads a lot of stuff. It's basically impossible to control that.

enter image description here

However there are certainly ways to modify the IPython startup under Tools -> Preferences -> IPython console, but I'm not sure if you can disable the SciPy import there.

Upvotes: 2

Related Questions