Is there a built-in IJulia function that list the kernels I have installed? I installed a kernel using installkernel and some time after I wanted to remove it with rm. I could remember the name I gave it but not the path IJulia uses to install the kernels, so I had to manually search my system.
It would be handy if IJulia could list the names and/or paths and I'm surprised that I couldn't find anything.
You can use IJulia.kerneldir() to get the directory holding kernels.
Then if you do e.g. readdir(IJulia.kerneldir(), join=true) you get a vector of directory names that can be used in rm.
Related
is there a way to setup a virtual environment in Julia using an environment file? (for instance like .yml file for creating conda venv)
Julia Version: 1.7.1
OS: Windows 10
In Julia virtual environment is defined via Project.toml file (that keeps package names and their acceptable versions) and Manifest.toml (that keeps the exact dependence tree and package versions generated along requirements defined in Project.toml).
Here is a sample Julia session:
julia> using Pkg
julia> pkg"generate MyProject"
Generating project MyProject:
MyProject/Project.toml
MyProject/src/MyProject.jl
julia> cd("MyProject")
julia> pkg"activate ."
Activating environment at `/home/ubuntu/MyProject/Project.toml`
Finally, note that you can manipulate the Project.toml by eg. adding a package like this (this assumes the environment is active):
pkg"add DataFrames"
Sometimes you want to provide package version information to your Project.toml, for an example you could add at the end of the file:
[compat]
DataFrames = "1.3.0"
After adding the first dependency the Mainifest.toml file has been generated. Copying this file together with Project.toml across machines allows you to duplicate the environment.
In order to have all packages installed on a new machine you will need to run:
pkg"activate ."
pkg"instatiate"
pkg"instatiate" can also be used to generate Mainfest.toml when only the Project.toml is present.
The nice thing is that Julia can store many package versions simultaneously and the virtual environments only links to the central package repository (contrary to Python that copies several GBs of data each time).
pkg provides this with project.toml files.
open julia in console
julia>]
Pkg> activate <Name>
<Name> Pkg> add <PackageName>
create directory with
The Julia Pkg documentation tells how to initiate an environment ($ activate $ENV-NAME), but it probably lacks the handy command to switch to the already created special environment. Also, I'm having trouble finding a command that shows all already created environments on the list, hence, if I have forgotten the names of the environments previously created, I need to do a manual search through the Julia-related folders...
So far, the verbatim help command in Julia REPL provides a poor description and so does the related Pkg-documentation webpage.
Another possible general answer to this predicament is to start using the Playground.jl module, which was recommended here on Medium:
However, the direct download attempt with Pkg repeatedly fails since the Pkg isn't able to find the package in the suggested GH project.
Thanks beforehand for any recommendations.
In package manager prompt just type activate # and press tab-key. The REPLs autocomplete will show you the possible environments.
If you are on a Mac or Linux
you can run this shell command to find all the "enviroment"
bash-3.2$ pwd
/Users/ssiew/juliascript
bash-3.2$ find . -name Project.toml
./Luxordir/Project.toml
./symata/Project.toml
I am encountering package compatibility issues within my global Julia environment for specific packages I want to use in a Jupyter notebook. Is there a way to tell IJulia to use a different environment instead of my global one?
The default IJulia kernel sets --project=#. so the most convenient way (IMO) is to just keep your project in the same folder as the notebook. 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. If there is no Project.toml in that directory, the default (global) environment will be used.
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.
With this, its possible to quickly switch between difference branches.
Now I have two Linux Distribution in two different partitions. I have a Data partition that is shared between them so they can use common files and folders. I have the same (major) version of R in both distributions. My question is:
Can I use a common R-package path so that I just need to install R-packages in one and can use in other?
What possible problems can I face in the situation?
Yes, you do.
Example the brew and conda which create a directory to all bins and libs installed with those packages.
So, consider using one of them. Anyway, you might include the binaries on ENV using the var PATH.
export PATH="my/binary/path:"$PATH
Additionally, you might prefer edit both installations .bashrc or .bash_profile adding a line to edit PATH.
Particularly, I like to create a .bashrc/ directory and include configuration files within (mypath.sh, myalias.sh, myfunctions.sh, ...) and call execution of all files with the directory just including a line on the bottom of the .bashrc file a line like this:
for file in ~/.bashrc.d/*;
do
source $file
done
This might work for packages with only R code. For packages with compiled code I do expect problems:
Do both Linux distributions use the same linker and compiler?
Do both Linux distributions use the same system libraries?
(a) I have Julia Studio 0.4.3 and the settings for libraries in my installation (Windows) point to C:/Program Files (x86)/JuliaStudio-0.4.3/julia-studio/Julia. Within that directory, I found julia-basic.exe, julia-debug.exe, julia-debug-readline.exe and julia-readline.exe. I didn't find julia.exe in that folder.
If I write a Julia file within Julia studio, but later I want to run it in cmd line or a bat file, which exe should I use?
Do I need to install Julia separately if I want to run Julia from cmd line or a bat file (Windows)?
(b) Also the Julia documentation says that I can start Julia with -p n option (where n is the number of workers). Is it possible to do this within Julia Studio?
Julia Studio uses the julia-basic executable. There is no julia executable, per se. Rather there is julia-basic and julia-readline executables, the later of which has GNU Readline capabilities. The debug versions of the executables included debug symbols in the executable--it does not sound like you need those.
You can add processors in the REPL with addprocs (link to docs). There is no requirement to define the number of processors up front when starting the Julia process.