O.k., finally found a solution that seems to work and not producing warning messages:
module TestPlot2
using Requires
export myplot
myplot(x,y) = println("... myplot(...) ignored, since PyPlot not available")
function __init__()
if !Requires.isprecompiling()
@eval Main begin
try
import PyPlot
catch
println("... PyPlot not available (plot commands will be ignored)")
end
end
end
@require PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" begin
myplot(x,y) = PyPlot.plot(x,y)
end
end
end