gpt4 book ai didi

julia - 如何在Julia的导入路径中添加本地项目?

转载 作者:行者123 更新时间:2023-12-04 19:25:09 25 4
gpt4 key购买 nike

我希望能够importusing在我的主Julia REPL/另一个项目或环境中的目录~/projects/ExamplePkg中编写的包。

最佳答案

]foo的意思是“在Julia Pkg REPL上使用foo命令”。在Julia REPL上键入]以输入Pkg REPL。使用]help <command name>获取更多信息,或查看下面的链接。

确保您的程序包具有一个Project.toml并为其提供一个UUID并对其进行命名(使用Julia REPL的]generate或PkgTemplates程序包生成一个),并且该文件位于git repo中,且至少包含一次提交(包括所有相关文件) 。

然后选择您想如何使用该软件包。

您可能想运行]dev ~/projects/ExamplePkg:

If dev is used on a local path, that path to that package is recorded and used when loading that package. The path will be recorded relative to the project file, unless it is given as an absolute path.



如果使用 dev并更改了 dev d程序包中的依赖项,则可能应该在所有依赖于该程序包的环境中运行 ]resolve

或者,您可以运行 ]add ~/projects/ExamplePkg:

Instead of giving a URL of a git repo to add we could instead have given a local path to a git repo. This works similarly to adding a URL. The local repository will be tracked (at some branch) and updates from that local repo are pulled when packages are updated. Note that changes to files in the local package repository will not immediately be reflected when loading that package. The changes would have to be committed and the packages updated in order to pull in the changes.



在<1.4版本的Julia中:如果在正确设置git repo之前不小心对软件包进行了 ]add编码,则可能会得到 ERROR: GitError(Code:EUNBORNBRANCH, Class:Reference, reference 'refs/heads/master' not found)。不幸的是,Julia可能已经缓存了不良 repo ,因此您需要将其从 ~/.julia/clones/<gibberish>/中删除。您可以使用grep找到要删除的目录: $ grep ExamplePkg ~/.julia/clones/*/config

文档: https://julialang.github.io/Pkg.jl/v1/managing-packages/

关于julia - 如何在Julia的导入路径中添加本地项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59571690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com