1

我执行 <include("C:\Users\Administrator\Desktop\ERGO.jl-main\notebooks\example.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:\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

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

4

1 回答 1

1

不要将包加载放在函数中:

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(). 原因是宏扩展发生在运行时之前。

于 2021-08-19T14:16:49.200 回答