# LoadError: UndefVarError: Printf not defined

**URL:** <https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 1, 2021, 8:30am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482 "2021-09-01T08:30:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goh/32/28770_2.png) [@GoH](https://discourse.julialang.org/u/GoH)\
**Post date:** [September 1, 2021, 8:30am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/1 "2021-09-01T08:30:41Z")

</div>

Hi, I just found the @printf does not work for me. Here is the code. I run it on Pluto.

```julia
begin
	using Printf
	Printf.@printf
end

```

and the error is

```julia
LoadError: UndefVarError: Printf not defined

in expression starting at /Users/ **** #==#d3be98a9-e87d-4929-8dc4-a5151493f823:3

1. <mark> **top-level scope** </mark>@ *:0*

```

Can anyone help?

---

<div class="post-metadata">

**Author:** ![JonasIsensee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonasisensee/32/4704_2.png) [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)\
**Post date:** [September 1, 2021, 8:35am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/2 "2021-09-01T08:35:27Z")

</div>

Hi @GoH,

julia tries to evaluate your `begin ... end` block in a single go.  
Macros are some of the first things that are expanded.  
However, the macro `@printf` is only defined when calling `using Printf`.  
So, this can not work.

Try splitting the package loading into a separate blocks / cells.

---

<div class="post-metadata">

**Author:** ![GoH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goh/32/28770_2.png) [@GoH](https://discourse.julialang.org/u/GoH)\
**Post date:** [September 1, 2021, 9:20am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/3 "2021-09-01T09:20:32Z")

</div>

Thank you @JonasIsensee

[1h](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/2)

I split the codes into two cells in Pluto, and the error is gone, but @printf does not print out anything… If I run the code in Julia interface, it works. Here is what happened:

 ![Screen Shot 2021-09-01 at 11.20.08](https://global.discourse-cdn.com/julialang/original/3X/d/1/d17f326a4e9ec19045445a907c92cafefbe0983c.png)

---

<div class="post-metadata">

**Author:** ![GoH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goh/32/28770_2.png) [@GoH](https://discourse.julialang.org/u/GoH)\
**Post date:** [September 1, 2021, 9:21am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/4 "2021-09-01T09:21:03Z")

</div>

and in Julia interface, it works

![Screen Shot 2021-09-01 at 11.20.19](https://global.discourse-cdn.com/julialang/original/3X/5/3/530db727cd42149dabbde00a0e2163664cf9c35e.png)

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [September 1, 2021, 9:53am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/5 "2021-09-01T09:53:22Z")

</div>

See the section “I used print and display but nothing is happening!” on [https://github.com/fonsp/Pluto.jl/wiki/⚡-Writing-and-running-code](https://github.com/fonsp/Pluto.jl/wiki/%E2%9A%A1-Writing-and-running-code)

---

<div class="post-metadata">

**Author:** ![vargasje](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vargasje/32/29898_2.png) [@vargasje](https://discourse.julialang.org/u/vargasje)\
**Post date:** [August 3, 2024, 9:07pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/6 "2024-08-03T21:07:10Z")

</div>

begin  
using Printf  
Printf.@printf  
end

does not work for me

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [August 4, 2024, 12:11am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-printf-not-defined/67482/7 "2024-08-04T00:11:32Z")

</div>

This is the same error as in the original question. Try the solutions given above.
