2
我正在移植一個曾經在Julia 0.4和Julia 0.5工作並且遇到麻煩的程序。如何從包中遠程運行Julia函數?
這是程序:
addprocs(3)
ref = @spawn factor(21883298135690819)
factors = fetch(ref)
@assert factors == Dict(234711901=>1,93234719=>1)
當朱莉婭0.5運行時,我得到的錯誤
ERROR: On worker 2:
factor(21883298135690819,) has been moved to the package Primes.jl.
Run Pkg.add("Primes") to install Primes on Julia v0.5-
很公平。但即使我進入交互式終端,我的代碼仍然無法運行!這裏是成績單:
julia> Pkg.add("Primes")
INFO: Nothing to be done
julia> using Primes
julia> Primes.factor(21883298135690819)
Dict{Int64,Int64} with 2 entries:
234711901 => 1
93234719 => 1
julia> addprocs(3)
3-element Array{Int64,1}:
2
3
4
julia> ref = @spawn factor(21883298135690819)
Future(2,1,5,Nullable{Any}())
julia> factors = fetch(ref)
ERROR: On worker 2:
factor(21883298135690819,) has been moved to the package Primes.jl.
Run Pkg.add("Primes") to install Primes on Julia v0.5-
同樣的問題!
我讀過documentation似乎暗示using
聲明使代碼可用於所有進程,但情況並非如此。
我在做什麼錯?
把'addprocs(3)'放在'使用Primes'之前? – Gnimuc