Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install julia packages via command line

Tags:

docker

julia

I'm wondering if it's possible to run arbitrary julia code via the command like similar to python:

python -c "print('stuff')" 

or in R:

R -e '# do stuff'

because I'm building a docker container I'd like to be able to do something as shown above for Julia, currently I think I might be able to work around it like so:

&& echo 'packs=["Distributions", "CSV", "DataFrames", "ForwardDiff", "PyCall", "GLM"];for i in packs;Pkg.add(i);end' >> packs.jl \
&& julia packs.jl \

in the dockerfile, but then I wonder what if packages ask for permission like cario for example

like image 518
atomsmasher Avatar asked Jan 02 '23 03:01

atomsmasher


1 Answers

The following seems to work in Julia 0.6:

julia -e 'Pkg.add("DifferentialEquations.jl")'

With Julia 0.7-beta, it looks like you should do

julia -e 'using Pkg; Pkg.add("DifferentialEquations.jl")'

For multiple packages, you can use the dot suffix and provide a list.

Pkg.add.(["DifferentialEquations.jl", "Optim.jl"])
like image 84
Oliver Evans Avatar answered Jan 16 '23 21:01

Oliver Evans