LoadError: UndefVarError: Printf not defined

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

begin
	using Printf
	Printf.@printf
end

and the error is

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?

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.

1 Like

Thank you @JonasIsensee

1h

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:

and in Julia interface, it works

Screen Shot 2021-09-01 at 11.20.19

See the section “I used print and display but nothing is happening!” on https://github.com/fonsp/Pluto.jl/wiki/⚡-Writing-and-running-code

begin
using Printf
Printf.@printf
end

does not work for me

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