Skip to content

Commit ca59049

Browse files
authored
Merge pull request #43 from mwcraig/spyder-4
Accommodate change in spyder 4
2 parents ece9be5 + 751af1a commit ca59049

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

vpython/_notebook_helpers.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,26 @@ def __is_spyder():
77

88

99
def _spyder_run_setting_is_correct():
10-
from spyder.config.main import CONF
10+
try:
11+
# This is the spyder 3 location
12+
from spyder.config.main import CONF
13+
except ImportError:
14+
# CONF moved in spyder 4
15+
from spyder.config.manager import CONF
16+
1117
# Use this instead of accessing like a dictionary so that a
1218
# default value can be supplied if the setting is missing.
1319
return CONF.get('run', 'default/interpreter/dedicated', False)
1420

1521

1622
def _warn_if_spyder_settings_wrong():
17-
if not _spyder_run_setting_is_correct():
23+
from spyder import __version__
24+
from packaging import version
25+
pre_4 = version.parse(__version__) < version.parse('4.0.0')
26+
# It looks like spyder 4 works fine without this setting, perhaps
27+
# related to the change that they run files in an empty namespace
28+
# instead of the namespace of the current console.
29+
if not _spyder_run_setting_is_correct() and pre_4:
1830
print('\x1b[1;31m**** Please set spyder preference Run to '
1931
'"Execute in a dedicated console" for the best '
2032
'vpython experience. ****\x1b[0m')

0 commit comments

Comments
 (0)