“Julia doesn’t find packages in depot_path anymore.”

huangapple go评论62阅读模式
英文:

Julia doesn't find packages in depot_path anymore

问题

I have a problem with using packages in Julia. It has worked before, and I'm not really sure why this has changed or how to troubleshoot.

I have a folder /my_path/julia/packages with Julia packages. For example, there is a folder /my_path/julia/packages/FFTW/ with the FFTW package.

Further, I have changed the depot path to point at this directory by assigning JULIA_DEPOT_PATH before starting julia, so that Base.DEPOT_PATH = ["/my_path/julia/"]

However, if I run julia> using FFTW, I get the following error message:

ERROR: ArgumentError: Package FFTW not found in current path:

  • Run import Pkg; Pkg.add("FFTW") to install the FFTW package.

Any idea how I can troubleshoot or fix this?

英文:

I have a problem with using packages in Julia. It has worked before, and I'm not really sure why this has changed or how to troubleshoot.

I have a folder
/my_path/julia/packages
with Julia packages. For example, there is a folder
/my_path/julia/packages/FFTW/
with the FFTW package.
Further, I have changed the depot path to point at this directory by assigning JULIA_DEPOT_PATH before starting julia, so that

Base.DEPOT_PATH = ["/my_path/julia/"]

However, if I run
julia> using FFTW
I get the following error message:
>ERROR: ArgumentError: Package FFTW not found in current path:

  • Run `import Pkg; Pkg.add("FFTW")` to install the FFTW package.

Any idea how I can troubleshoot or fix this?

答案1

得分: 2

Manipulating Base.DEPOT_PATH does not seem like a good idea.
The code proposed by @cmc will not work (at least on Julia 1.3.1):

julia> Base.DEPOT_PATH = ["/some/path"]
ERROR: cannot assign variables in other modules

There is a workaround:

Base.DEPOT_PATH[1] = "/some/path"

However, the correct way is to assign the JULIA_DEPOT_PATH system variable before starting Julia, Windows:

set JULIA_DEPOT_PATH=c:\some\path

or

set JULIA_DEPOT_PATH=c:\some\path1;c:\some\path2

Linux/OSX:

export JULIA_DEPOT_PATH=/some/path

or

export JULIA_DEPOT_PATH=/some/path1:/some/path2
英文:

Manipulating Base.DEPOT_PATH does not seem like a good idea.
The code proposed by @cmc will does not work (at least on Julia 1.3.1):

julia> Base.DEPOT_PATH = ["/some/path"]
ERROR: cannot assign variables in other modules

There is a workaround:

Base.DEPOT_PATH[1] = "/some/path"

However, the correct way is to assign the JULIA_DEPOT_PATH system variable before starting Julia, Windows:

set JULIA_DEPOT_PATH=c:\some\path

or

set JULIA_DEPOT_PATH=c:\some\path1;c:\some\path2

Linux/OSX:

export JULIA_DEPOT_PATH=/some/path

or

export JULIA_DEPOT_PATH=/some/path1:/some/path2

答案2

得分: 2

除非你有特定的原因这样做(如果是这种情况,我会很感兴趣听听!),你不需要去调整 DEPOT_PATHLOAD_PATH 变量:通常情况下,使用 Julia 的包管理器应该足够满足你的需求。

在这个特定情况下,你尝试按照错误消息建议的做法了吗?

julia> import Pkg
julia> Pkg.add("FFTW")
英文:

Unless you have a specific reason to do so (and if this is the case I'd be interested to hear it!), you don't need to fiddle with the DEPOT_PATH or LOAD_PATH variables: using Julia's package manager should be enough to cover your needs most of the time.

In this specific instance, have you tried to do what the error message suggests?

julia> import Pkg
julia> Pkg.add("FFTW")

答案3

得分: 1

LOAD_PATH 会修改代码加载,而不是 DEPOT_PATH

你想要像这样执行:push!(LOAD_PATH, /my_path/julia/packages)

我会echo @ffevotte并强烈建议只在必要时修改 LOAD_PATH。通过 Pkg.add 显式声明它们的小开销远远超过了将依赖项组织到Pkg环境中的好处。

英文:

LOAD_PATH, not DEPOT_PATH, will modify code loading.

You want to do something like push!(LOAD_PATH, /my_path/julia/packages).

I will echo @ffevotte and strongly suggest to not modify LOAD_PATH unless necessary. The benefits of organizing dependencies into Pkg environments far outweigh the small overhead of declaring them explicitly through Pkg.add.

huangapple
  • 本文由 发表于 2020年1月4日 00:14:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581806.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定