julia LoadError: UndefVarError: @showprogress not defined



我执行<include("C:UsersAdministratorDesktopERGO.jl-mainnotebooksexample.jl")>,但报告错误。以下是部分代码:

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:UsersAdministratorDesktopERGO.jl-mainnotebooksexample.jl:53
in expression starting at C:UsersAdministratorDesktopERGO.jl-mainnotebooksexample.jl:4

我不知道如何解决这个错误,有人能帮我吗?非常感谢!

不要把包加载放在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)

把它们放在你的main()之外。原因是宏展开发生在运行前。

最新更新