简体   繁体   English

如何为 IJulia Jupyter 笔记本设置 Julia 环境?

[英]How to set Julia Environment for IJulia Jupyter notebook?

I am encountering package compatibility issues within my global Julia environment for specific packages I want to use in a Jupyter notebook.我在我的全局 Julia环境中遇到了我想在 Jupyter 笔记本中使用的特定包的包兼容性问题。 Is there a way to tell IJulia to use a different environment instead of my global one?有没有办法告诉 IJulia 使用不同的环境而不是我的全局环境?

The default IJulia kernel sets --project=@.默认的 IJulia 内核设置--project=@. so the most convenient way (IMO) is to just keep your project in the same folder as the notebook.所以最方便的方法 (IMO) 是将您的项目保存在与笔记本相同的文件夹中。 The result is that the correct project is used from the start and you don't have to worry about activating it while in the notebook.结果是从一开始就使用了正确的项目,您不必担心在笔记本中激活它。

You can always start up a notebook, and within a cell run您始终可以启动笔记本,并在单元格内运行

using Pkg
Pkg.activate("./path/to/folder")

When starting the notebook type:启动笔记本类型时:

notebook(dir="/path/to/your/environment/")

This will launch Jupyter notebook loading the environment (Project.toml) in the directory that you have specified.这将启动 Jupyter notebook,在您指定的目录中加载环境 (Project.toml)。 If there is no Project.toml in that directory, the default (global) environment will be used.如果该目录中没有 Project.toml,则将使用默认(全局)环境。

Depending on the complexity of your setup, you might want to consider Lmod I use this with a module hierarchy: 1. Core module, 2. Compiler modules, MPI modules.根据设置的复杂性,您可能需要考虑Lmod我将其与模块层次结构一起使用:1. 核心模块,2. 编译器模块,MPI 模块。 With this, its possible to quickly switch between difference branches.有了这个,可以在不同的分支之间快速切换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM