rodrigolece
rodrigolece

Reputation: 1109

Julia: how do I configure IJulia kernel to use specific environment?

I downloaded someone else's project and the structure is as follows:

project/
    notebooks/
        notebook_a.ipynb
        notebook_b.ipynb
    library/
        Manifest.toml
        Project.toml
        src/
        test/

In the notebooks I would like to import library, and install its dependencies within its own evironment.

Following the sugestions here, I can do

using Pkg
Pkg.activate("../library/")

but I wonder if I could install a kernel that has the project directory specified and automatically activates the library environment. What should I pass to IJulia's installkernel? "--project=..." what?

I use conda regularly and this confused me because I thought that running notebook once the environment is activated in the command line would have the right environment in the notebook, but this was not the case.

Upvotes: 1

Views: 646

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42194

IJulia starts its own Julia process and hence is not using environment settings from its master.

By default IJulia sets the environment (Project.toml) from the folder it was started. The most convenient thing would be to move the notebooks folder to be subfolder of library and then just run:

notebook(dir="/path/to/project/library")

If you do not want to change the folder structure you still need to run:

notebook(dir="/path/to/project/notebooks")

Once in the notebook you need to run:

using Pkg
pkg"activate /path/to/project/library"

Upvotes: 2

Related Questions