Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
ae8fa7f
1
Parent(s):
b7ca126
Automatically load ipython extension
Browse files- pysr/julia_import.py +13 -0
pysr/julia_import.py
CHANGED
@@ -31,6 +31,19 @@ else:
|
|
31 |
):
|
32 |
os.environ[k] = os.environ.get(k, default)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
from juliacall import Main as jl # type: ignore
|
36 |
|
|
|
31 |
):
|
32 |
os.environ[k] = os.environ.get(k, default)
|
33 |
|
34 |
+
try:
|
35 |
+
get_ipython = sys.modules["IPython"].get_ipython
|
36 |
+
|
37 |
+
if "IPKernelApp" not in get_ipython().config:
|
38 |
+
raise ImportError("console")
|
39 |
+
|
40 |
+
print("Detected Jupyter notebook. Loading juliacall extension.")
|
41 |
+
|
42 |
+
# TODO: Turn this off if juliacall does this automatically
|
43 |
+
get_ipython().run_line_magic("load_ext", "juliacall")
|
44 |
+
except Exception:
|
45 |
+
pass
|
46 |
+
|
47 |
|
48 |
from juliacall import Main as jl # type: ignore
|
49 |
|