@@ -93,7 +93,10 @@ def new_ipy(s=''):
93
93
new_ipy()
94
94
95
95
"""
96
- from IPython .kernel import KernelManager
96
+ try :
97
+ from jupyter_client .manager import KernelManager
98
+ except ImportError :
99
+ from IPython .kernel import KernelManager
97
100
km = KernelManager ()
98
101
km .start_kernel ()
99
102
return km_from_string (km .connection_file )
@@ -107,21 +110,28 @@ def km_from_string(s=''):
107
110
import IPython
108
111
except ImportError :
109
112
raise ImportError ("Could not find IPython. " + _install_instructions )
110
- from IPython .config .loader import KeyValueConfigLoader
111
113
try :
112
- from IPython .kernel import (
113
- KernelManager ,
114
- find_connection_file ,
115
- )
114
+ from traitlets .config .loader import KeyValueConfigLoader
115
+ except ImportError :
116
+ from IPython .config .loader import KeyValueConfigLoader
117
+ try :
118
+ from jupyter_client .manager import KernelManager
119
+ from jupyter_client .connect import find_connection_file
116
120
except ImportError :
117
- # IPython < 1.0
118
- from IPython .zmq .blockingkernelmanager import BlockingKernelManager as KernelManager
119
- from IPython .zmq .kernelapp import kernel_aliases
120
121
try :
121
- from IPython .lib .kernel import find_connection_file
122
+ from IPython .kernel import (
123
+ KernelManager ,
124
+ find_connection_file ,
125
+ )
122
126
except ImportError :
123
- # < 0.12, no find_connection_file
124
- pass
127
+ # IPython < 1.0
128
+ from IPython .zmq .blockingkernelmanager import BlockingKernelManager as KernelManager
129
+ from IPython .zmq .kernelapp import kernel_aliases
130
+ try :
131
+ from IPython .lib .kernel import find_connection_file
132
+ except ImportError :
133
+ # < 0.12, no find_connection_file
134
+ pass
125
135
126
136
global km , kc , send
127
137
@@ -147,8 +157,13 @@ def km_from_string(s=''):
147
157
echo (":IPython " + s + " failed" , "Info" )
148
158
echo ("^-- failed '" + s + "' not found" , "Error" )
149
159
return
150
- km = KernelManager (connection_file = fullpath )
151
- km .load_connection_file ()
160
+ if IPython .version_info [0 ] >= 4 :
161
+ km = KernelManager ()
162
+ km .connection_file = find_connection_file ()
163
+ km .load_connection_file ()
164
+ else :
165
+ km = KernelManager (connection_file = fullpath )
166
+ km .load_connection_file ()
152
167
else :
153
168
if s == '' :
154
169
echo (":IPython 0.11 requires the full connection string" )
0 commit comments