问题:无法在 Julia 中打开文件

刚刚从 GitHub 中提取了一个存储库并保存在“下载”下。尝试运行程序并不断收到这些错误:

    julia> using FITSIO

    julia> include("readoifits.jl")
    ERROR: could not open file /home/ellie/Downloads/readoifits.jl
    in include_from_node1(::String) at ./loading.jl:488

    julia> include("setupft.jl")
    ERROR: could not open file /home/ellie/Downloads/setupft.jl
    in include_from_node1(::String) at ./loading.jl:488

    julia> include("oichi2.jl")
    ERROR: could not open file /home/ellie/Downloads/oichi2.jl
    in include_from_node1(::String) at ./loading.jl:488

    julia> include("oiplot.jl")
    ERROR: could not open file /home/ellie/Downloads/oiplot.jl
    in include_from_node1(::String) at ./loading.jl:488

所以它知道文件存在以及它的位置,但无法打开它们。有人可以解释一下 node1 和 String 位的含义以及如何打开这些文件吗?谢谢。

解答

你当前的目录是什么?您似乎正在“下载”目录中运行 REPL——其中可能包含您的数据但没有您的代码?您可以使用pwd()函数找到当前目录。 REPL 中的include函数打开相对于当前工作目录的文件,该目录是您启动 Julia 进程时所在的目录。 (当从另一个源文件调用时,include会查找相对于该源文件目录的文件。)

Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐