I have a .jl file at /Users/myuser/Documents/JuliaLearn/Julia/mysource.jl
In Julia Repl, I'm trying to run as:
include("/Users/myuser/Documents/JuliaLearn/Julia/mysource.jl")
But get this error:
ERROR: could not open file
/Users/myuser/~/Documents/JuliaLearn/Julia/mysource.jl in include at
/Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
in include_from_node1 at
/Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
I also tried but get an error similar to the above:
include("~/Documents/JuliaLearn/Julia/mysource.jl")
Any idea what I'm doing wrong?
解决方案
Isomorphic to OS:
cd(joinpath(homedir(),"a_long","path","to_your","files"));
include("your_julia_file.jl")
在Julia REPL中尝试运行`include()`命令加载.jl文件时遇到错误,错误提示显示无法打开指定路径的文件。尝试使用相对路径和 tilde(~)符号同样失败。解决方案是使用`cd()`函数结合`joinpath()`改变工作目录到文件所在位置,然后再执行`include()`。

9739

被折叠的 条评论
为什么被折叠?



