# How to use redirect\_stdout in IJulia (Jupyter notebook)

**URL:** <https://discourse.julialang.org/t/how-to-use-redirect-stdout-in-ijulia-jupyter-notebook/52230>\
**Category:** New to Julia\
**Tags:** ijulia, io\
**Created:** [December 22, 2020, 4:08pm UTC](https://discourse.julialang.org/t/how-to-use-redirect-stdout-in-ijulia-jupyter-notebook/52230 "2020-12-22T16:08:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuhua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuhua/32/27618_2.png) [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Post date:** [December 22, 2020, 4:08pm UTC](https://discourse.julialang.org/t/how-to-use-redirect-stdout-in-ijulia-jupyter-notebook/52230/1 "2020-12-22T16:08:08Z")

</div>

The following `redirect_stdout` code works as expected in REPL

```julia
original_stdout = stdout
(rd, wr) = redirect_stdout()
println("123")
println("456")
redirect_stdout(original_stdout)
close(wr)
read(rd, String) 

```

The output is `"123\n456\n"`.

However, if we paste the above code into IJulia (a Jupyter notebook), the last line `read` will block. Any suggestions on using `redirect_stdout` in IJulia?

```julia
julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, sandybridge)

```

---

<div class="post-metadata">

**Author:** ![DGothrek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgothrek/32/23941_2.png) [@DGothrek](https://discourse.julialang.org/u/DGothrek)\
**Post date:** [April 12, 2021, 10:00pm UTC](https://discourse.julialang.org/t/how-to-use-redirect-stdout-in-ijulia-jupyter-notebook/52230/2 "2021-04-12T22:00:10Z")

</div>

I’m experiencing the same issue. Would appreciate if anyone had a lead. I’m going to investigate more on that.
