julia - 如何将依赖项添加到我的 Julia 包中?
问题描述
我在 Julia 中创建了一个包(我们称之为 package_name);文件结构已经与 Project.toml 和 Manifest.toml 文件一起生成,并且我在创建包时已经添加了一些依赖项。
我忘了添加依赖项,我想让 REPL 显示:
(package_name) pkg >
这样我就可以输入
add dependency_name
我如何让 REPL 显示这个?我想我需要转到包文件夹并(重新)激活包,但我无法使用 cd 导航到它。
显示我应该在 REPL 中输入的确切命令会很有帮助。
解决方案
为了获得包 REPL 模式],您应该在光标位于行首时键入一个右括号。同样,在 package REPL 模式下,您需要BackSpc在提示符后立即键入以返回标准 REPL 模式:
julia> # type ] here to enter the Pkg REPL
# We're now in the Pkg REPL, but the default environment is active
# Let's activate the environment we want
# (replace the path below with "." to activate the environment defined in the current working directory)
(@v1.5) pkg> activate /path/to/package
# Now we see that the correct environment is active
# This is where new dependencies will be added
(package_name) pkg> add DepName
(package_name) pkg> # type BackSpace here to get back to the standard REPL
julia>
此外,通过使用库pkg"..."
中定义的字符串宏,您可以在不进入 Pkg REPL 模式的情况下实现相同的目的Pkg
:
julia> using Pkg
julia> pkg"activate /path/to/package"
julia> pkg"add DepName"
推荐阅读
- ruby-on-rails - 本地 rake 任务需要开发 gems 在生产组中
- haskell - 用于嵌套容器的索引镜头
- r - R:如果 colA 中的 8 个字符的子字符串等于 colB 中的 8 个字符的子字符串,则将 colA 的值添加到新的 colC
- java - 下载网页内容 - 长时间下载
- systemd - 未知 systemd 调用类似 weirf 的命令
- file - Spring Boot-Camel 应用程序中的文件轮询器实现
- python - 将 CUDA 与 pytorch 一起使用?
- spring - 是否可以在@Cacheable spring 中使用我想要的缓存?
- google-apps-script - 仅将值从一张纸复制到另一张纸
- r - 如何将选定的行转换为 R 中的列?