Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython crash when error occurs after import tyjuliacall julia module #3

Open
songjhaha opened this issue Sep 7, 2022 · 4 comments

Comments

@songjhaha
Copy link
Member

songjhaha commented Sep 7, 2022

Python's original repl works fine

In [1]: from tyjuliacall import Main

In [2]: Main.eval(Main.Meta.parse("struct Point x end"))

In [3]: a = Main.Point(1)

In [4]: a*a # try to
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "/home/songjhaha/miniconda3/envs/dev/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-ac686954dc0d>", line 1, in <module>
    a*a
  File "/home/songjhaha/miniconda3/envs/dev/lib/python3.7/site-packages/tyjuliasetup/jv.py", line 64, in __mul__
    return __jl_mul__(self, other)
RuntimeError: MethodError: no method matching length(::Point)
Closest candidates are:
  length(!Matched::Union{Base.KeySet, Base.ValueIterator}) at ~/.jnumpy/julias/julia-1.7/share/julia/base/abstractdict.jl:58
  length(!Matched::Union{LinearAlgebra.Adjoint{T, S}, LinearAlgebra.Transpose{T, S}} where {T, S}) at ~/.jnumpy/julias/julia-1.7/share/julia/stdlib/v1.7/LinearAlgebra/src/adjtrans.jl:171
  length(!Matched::Base.InvasiveLinkedListSynchronized) at ~/.jnumpy/julias/julia-1.7/share/julia/base/task.jl:604
  ...
Stacktrace:
 [1] _similar_shape(itr::Point, #unused#::Base.HasLength)
   @ Base ./array.jl:600
 [2] _collect(cont::UnitRange{Int64}, itr::Point, #unused#::Base.HasEltype, isz::Base.HasLength)
   @ Base ./array.jl:655
 [3] collect(itr::Point)
   @ Base ./array.jl:649
 [4] broadcastable(x::Point)
   @ Base.Broadcast ./broadcast.jl:704
 [5] broadcasted(::Function, ::Point, ::Point)
   @ Base.Broadcast ./broadcast.jl:1300
 [6] jl_mul(self::TyPython.CPython.Py, other::TyPython.CPython.Py)
   @ TyJuliaSetup ~/miniconda3/envs/dev/lib/python3.7/site-packages/tyjuliasetup/src/TyJuliaSetup.jl:320
 [7] jl_mul(self::Ptr{TyPython.CPython.PyObject}, _vectorargs::Ptr{TyPython.C.Ptr{TyPython.CPython.PyObject}}, argc::Int64)
   @ TyJuliaSetup ~/miniconda3/envs/dev/lib/python3.7/site-packages/jnumpy/TyPython/src/CPython.Dev.jl:90
 [8] jl_mul(self::Ptr{TyPython.CPython.PyObject}, _vectorargs::Ptr{TyPython.C.Ptr{TyPython.CPython.PyObject}}, argc::Int64)
   @ TyJuliaSetup ~/miniconda3/envs/dev/lib/python3.7/site-packages/jnumpy/TyPython/src/CPython.Dev.jl:111

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/songjhaha/miniconda3/envs/dev/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2099, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'RuntimeError' object has no attribute '_render_traceback_'
...
@songjhaha
Copy link
Member Author

Maybe it's the problem of my IPython. After import tyjuliacall.Main, then try to trigger some error, IPython crashes.

same error message:

In [1]: from tyjuliacall import Main

In [2]: a
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "/home/songjhaha/miniconda3/envs/pycall/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-3f786850e387>", line 1, in <module>
    a
NameError: name 'a' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/songjhaha/miniconda3/envs/pycall/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2099, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'NameError' object has no attribute '_render_traceback_'
...

@songjhaha songjhaha changed the title IPython crash when julia error occurs IPython crash when error occurs after import tyjuliacall julia module Sep 7, 2022
@thautwarm
Copy link
Member

The support for IPython is very limited. Shall we just remove the following line?

def _repr_pretty_(self, p, cycle):

@thautwarm
Copy link
Member

A simple gooling shows that this might not be related to tyjuliacall. It's related to virtualenv.

microsoft/vscode-jupyter#9306

microsoft/vscode-jupyter#9306 (comment)

Your python environment is kinda mismatched. You have Python 3.8 with a much newer IPython. They're likely not compatible.

@songjhaha
Copy link
Member Author

that's true, a new env with python 3.8 works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants