Skip to content

Commit c2141ac

Browse files
authored
Merge pull request #1357 from jbexta/main
Allow running from an executable
2 parents 6a5d274 + 91091bb commit c2141ac

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

interpreter/core/computer/terminal/languages/jupyter_language.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import ast
77
import logging
8+
import sys
89
import os
910
import queue
1011
import re
@@ -18,6 +19,17 @@
1819

1920
DEBUG_MODE = False
2021

22+
# When running from an executable, ipykernel calls itself infinitely
23+
# This is a workaround to detect it and launch it manually
24+
if 'ipykernel_launcher' in sys.argv:
25+
if sys.path[0] == '':
26+
del sys.path[0]
27+
28+
from ipykernel import kernelapp as app
29+
30+
app.launch_new_instance()
31+
sys.exit(0)
32+
2133

2234
class JupyterLanguage(BaseLanguage):
2335
file_extension = "py"

0 commit comments

Comments
 (0)