-
Notifications
You must be signed in to change notification settings - Fork 67
PythonCall not working in Jupyter Notebook in VSCode #601
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
Comments
To extract values you can pass a named tuple type specifying what to keep, like pyexec(@NamedTuple{ans::BigInt}, """
.......
ans = fib(y)
""", Main, (y=x,)) Also see the |
Hi Christopher, A great thanks for your kind help. Thanks for your suggestion by using pyexec, nevertheless, the following code still does not work as I get the following error message:
Did I do something wrong. Also I am confused why you suggest to use Many thanks for your kind help, function PYTHON_2_JULIA(x)
fib(x) = pyexec(@NamedTuple{ans::BigInt},"""
def fib(n):
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
ans = fib(y)
""", Main, (y=x,))
C = fib(x)
println(C)
return C
end
|
I found an alternative solution by using as you suggested by using ** PythonCall.@PYEXEC** function PYTHON_2_JULIA(P_Int, P_Float, P_String, P_Vector)
PythonCall.@pyexec """
def PYTHON_2_JULIA(P_Int, P_Float, P_String, P_Vector):
P_Int1 = P_Int + 1
P_Float1 = P_Float * 2.0
P_String1 = P_String + P_String
P_Vector1 = P_Vector + P_Vector
return P_Int1, P_Float1, P_String1, P_Vector1
"""=> PYTHON_2_JULIA
P_Int1, P_Float1, P_String1, P_Vector1 = PythonCall.pyconvert(Any, PYTHON_2_JULIA(P_Int, P_Float, P_String, P_Vector))
return P_Int1, P_Float1, P_String1, P_Vector1
end To run it:
This gives as expected
|
Glad it's working now, I'll close the issue as resolved. BTW the reason the previous |
Thanks @cjdoris , the idea is to wrap up some pyflwdir python package. Would you know how to call for e.g. numpy package into the example? Thanks for any help you may provide. |
Affects: PythonCall
Describe the bug
The PythonCall is not working in Jupyter Notebook in VScode.
The answer to fib(100) problem see below is nothing. Nevertheless the code works beautifully in REPL.
Many thanks for any help you may provide.
Your system
Please provide detailed information about your system:
Additional context
The text was updated successfully, but these errors were encountered: