julia LoadError: UndefVarError: @showprogress not defined

353 Views Asked by At

I excute <include("C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.jl")>,but it reports erro.Here is part of the codes:

function main()
using Images, ImageView, DataFrames, CSV, Statistics, LinearAlgebra
import Glob
import Distributions
import JSON
import ImageMagick
using Logging
import Gtk
import DataStructures
import CSV
import Random
import StatsPlots
import ProgressMeter.@showprogress
## These are const, if you change them while this notebook is running behavior will be undefined.
const ROI_PX = 7; # --> ROI is 7*2+1 x 7*2+1 pixels
const PX_NM = 100; # 1 pixel is 100nm
const FRAMESIZE=64; # x/y dim of frame
rootpath = "../data"
@assert ispath(rootpath)
fpath = joinpath(rootpath, "sequence-MT0.N1.HD-AS-Exp-as-list");
pospath = rootpath
outdir = joinpath(rootpath, "output")
if !ispath(outdir)
    mkpath(outdir)
end
@info "Using $(fpath) as inputdirectory, $(outdir) as output"
....
end


**ERROR: LoadError: LoadError: UndefVarError: @showprogress not defined**
Stacktrace:
 [1] top-level scope
   @ :0
 [2] include(fname::String)
   @ Base.MainInclude .\client.jl:444
 [3] top-level scope
   @ none:1
in expression starting at C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.jl:53
in expression starting at C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.jl:4

I don't know how to solve this error, could someone help me ? Thanks a lot!

1

There are 1 best solutions below

3
On

don't put package loading inside function:

julia> function main()
           import ProgressMeter.@showprogress
           @showprogress for _ = 1:10
               
           end
       end
ERROR: LoadError: UndefVarError: @showprogress not defined
in expression starting at REPL[1]:3

julia> import ProgressMeter.@showprogress

julia> function main()
           @showprogress for _ = 1:10
               
           end
       end
main (generic function with 1 method)

put them outside of your main(). The reason is that macro expansion happens before runtime.