How to install a package in Julia 1.0 (UndefVarError: Pkg not defined)

  • A+

I installed Julia 1.0, and want to make a simple plot. The first step is to type this on Julia:


However, an error occurs:

ERROR: UndefVarError: Pkg not defined. 

The same thing happens when I type:


What's the best way to install a package in Julia? I use MacOS.


In Julia 1.0, there are two ways to install a package. First, you can do

using Pkg Pkg.add("Packagename") 

or you can use the Pkg REPL mode by pressing ] (similar to ?, help mode, and ;, shell mode):

(v1.0) pkg> add Packagename 

You can find more information here: and here (live demo):

Julia 1.0 is brand new. It has been released a few days ago, so some packages aren't yet compatible with 1.0. Sometimes it helps to install the master branch of a package instead of the last tagged release. On my machine I had to do

(v1.0) pkg> add LaTeXStrings#master (v1.0) pkg> add PyPlot 

to get PyPlot to work. Hope this helps.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: