# PythonCall not working in Jupyter Notebook in VSCode

**URL:** <https://discourse.julialang.org/t/pythoncall-not-working-in-jupyter-notebook-in-vscode/127841>\
**Category:** Jupyter-Notebook\
**Tags:** jupyter, interoperability, python, vscode, pythoncall\
**Created:** [April 8, 2025, 12:43pm UTC](https://discourse.julialang.org/t/pythoncall-not-working-in-jupyter-notebook-in-vscode/127841 "2025-04-08T12:43:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [April 8, 2025, 12:43pm UTC](https://discourse.julialang.org/t/pythoncall-not-working-in-jupyter-notebook-in-vscode/127841/1 "2025-04-08T12:43:20Z")

</div>

The **PythonCall** is not working in **Jupyter Notebook** in **VScode**. The answer to _**fib(100)**_ is _nothing_. Nevertheless the code works beautifully in **REPL**.

Many thanks for any help you may provide.

```julia
using PythonCall

fib(x) = pyexec("""
def fib(n):
	a, b = 0, 1
	while a < n:
		print(a, end=' ')
		a, b = b, a+b
	print()
fib(y)
""", Main, (y=x,))

print(fib(10))

```

---

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [April 9, 2025, 1:25pm UTC](https://discourse.julialang.org/t/pythoncall-not-working-in-jupyter-notebook-in-vscode/127841/2 "2025-04-09T13:25:00Z")

</div>

I found an alternative solution by using \*\* PythonCall.@pyexec\*\*

```julia
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:

> P\_Int=1; P\_Float=2.0; P\_String=3; P\_Vector = [1.0, 2.0, 3.0, 4.0]  
> P\_Int1, P\_Float1, P\_String1, P\_Vector1 = .PYTHON\_2\_JULIA(P\_Int, P\_Float, P\_String, P\_Vector)
> 
> @show P\_Int1, P\_Float1, P\_String1, P\_Vector1
> 
> P\_Vector1[1]

_ **This gives as expected** _

```julia
(2, 4.0, 6, [2.0, 4.0, 6.0, 8.0])
2.0

```
