File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 128
128
StatementParser ,
129
129
shlex_split ,
130
130
)
131
+
132
+ # NOTE: When using gnureadline with Python 3.13, start_ipython needs to be imported before any readline-related stuff
133
+ try :
134
+ from IPython import start_ipython
135
+ except ImportError :
136
+ pass
137
+
131
138
from .rl_utils import (
132
139
RlType ,
133
140
rl_escape_prompt ,
@@ -4629,9 +4636,13 @@ def do_ipy(self, _: argparse.Namespace) -> Optional[bool]: # pragma: no cover
4629
4636
# Detect whether IPython is installed
4630
4637
try :
4631
4638
import traitlets .config .loader as TraitletsLoader # type: ignore[import]
4632
- from IPython import ( # type: ignore[import]
4633
- start_ipython ,
4634
- )
4639
+
4640
+ # Allow users to install ipython from a cmd2 prompt when needed and still have ipy command work
4641
+ try :
4642
+ start_ipython # noqa F823
4643
+ except NameError :
4644
+ from IPython import start_ipython
4645
+
4635
4646
from IPython .terminal .interactiveshell import ( # type: ignore[import]
4636
4647
TerminalInteractiveShell ,
4637
4648
)
You can’t perform that action at this time.
0 commit comments