關於julia的路徑問題,往往很重要!
一、關於julia的路徑問題
先檢視一下,模組或執行的資料夾的路徑是否在引導路徑上,
julia> LOAD_PATH
2-element Array{Union(ASCIIString,UTF8String),1}:
"D:\\Program Files\\JuliaStudio-0.4.4\\julia-studio\\julia\\local\\share\\julia\\site\\v0.2"
"D:\\ProgramFiles\\JuliaStudio-0.4.4\\julia-studio\\julia\\share\\julia\\site\\v0.2"
如果不在,將需要的路徑增加到引導路徑上。比如,新的模組的路徑為:
path ="D:/Program Files/JuliaStudio-0.4.4/julia-studio/share/qtcreator/Console/myModule";
# 增加模組路徑
julia> push!(LOAD_PATH,path)
3-element Array{Union(ASCIIString,UTF8String),1}:
"D:\\ProgramFiles\\JuliaStudio-0.4.4\\julia-studio\\julia\\local\\share\\julia\\site\\v0.2"
"D:\\ProgramFiles\\JuliaStudio-0.4.4\\julia-studio\\julia\\share\\julia\\site\\v0.2"
"D:/ProgramFiles/JuliaStudio-0.4.4/julia-studio/share/qtcreator/Console/myModule"
# 增加資料夾路徑Strategy
julia> push!(LOAD_PATH, "D:/ProgramFiles/JuliaStudio-0.4.4/julia-studio/share/qtcreator/Console/Strategy")
5-element Array{Union(ASCIIString,UTF8String),1}:
"D:\\ProgramFiles\\JuliaStudio-0.4.4\\julia-studio\\julia\\local\\share\\julia\\site\\v0.2"
"D:\\ProgramFiles\\JuliaStudio-0.4.4\\julia-studio\\julia\\share\\julia\\site\\v0.2"
"D:/ProgramFiles/JuliaStudio-0.4.4/julia-studio/share/qtcreator/Console/myModule"
"D:/ProgramFiles/JuliaStudio-0.4.4/julia-studio/share/qtcreator/Console/Strategy"
在增加完這些路徑後,系統就可以在這些路徑下查詢你所說的檔案或模組!否則就容易發生類似
“LoadError("D:/ProgramFiles/JuliaStudio-0.4.4/julia-studio/share/qtcreator/Console/test.jl",3,ErrorException("ToolModulenot found"))”
二、 設定當前工作目錄
pwd() :→ Get the current working directory. 獲取當前工作目錄的函式
cd(dir::String) :Set the current working directory. Returns the new current directory. 設定新的工作目錄
homedir() :→ Return the current user’s home directory.