- Getting Started with Julia
- Ivo Balbaert
- 409字
- 2021-07-23 20:34:06
Packages
Most of the standard library in Julia (can be found in /share/julia/base
relative to where Julia was installed) is written in Julia itself. The rest of Julia's code ecosystem is contained in packages that are simply Git
repositories. They are most often authored by external contributors, and already provide functionality for such diverse disciplines such as bioinformatics, chemistry, cosmology, finance, linguistics, machine learning, mathematics, statistics, and high-performance computing. A searchable package list can be found at http://pkg.julialang.org/. Official Julia packages are registered in the METADATA.jl
file in the Julia Git repository, available on GitHub at https://github.com/JuliaLang/METADATA.jl
.
Julia's installation contains a built-in package manager Pkg
for installing additional Julia packages written in Julia. The downloaded packages are stored in a cache ready to be used by Julia given by Pkg.dir()
, which are located at c:\users\username\.julia\vn.m\.cache
, /home/$USER/.julia/vn.m/.cache
, or ~/.julia/vn.m/.cache
. If you want to check which packages are installed, run the Pkg.status()
command in the Julia REPL, to get a list of packages with their versions, as shown in the following screenshot:

Packages list
The Pkg.installed()
command gives you the same information, but in a dictionary form and is usable in code. Version and dependency management is handled automatically by Pkg
. Different versions of Julia can coexist with incompatible packages, each version has its own package cache.
Tip
If you get an error with Pkg.status()
such as ErrorException("Unable to read directory METADATA.")
, issue a Pkg.init()
command to create the package repository folders, and clone METADATA
from Git. If the problem is not easy to find or the cache becomes corrupted somehow, you can just delete the .julia
folder, enter Pkg.init()
, and start with an empty cache. Then, add the packages you need.
Adding a new package
Before adding a new package, it is always a good idea to update your package database for the already installed packages with the Pkg.update()
command. Then, add a new package by issuing the Pkg.add("PackageName")
command, and execute using PackageName
in code or in the REPL. For example, to add 2D plotting capabilities, install the Winston package with Pkg.add("Winston ")
. To make a graph of 100 random numbers between 0 and 1, execute the following commands:
using Winston plot(rand(100))
The rand(100)
function is an array with 100 random numbers. This produces the following output:

A plot of white noise with Winston
After installing a new Julia version, update all the installed packages by running Pkg.update()
in the REPL. For more detailed information, you can refer to http://docs.julialang.org/en/latest/manual/packages/.
- Android Jetpack開發(fā):原理解析與應(yīng)用實(shí)戰(zhàn)
- Clojure for Domain:specific Languages
- Rust Cookbook
- 小程序,巧運(yùn)營:微信小程序運(yùn)營招式大全
- Visual Basic程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)(第4版)
- PhoneGap Mobile Application Development Cookbook
- jQuery開發(fā)基礎(chǔ)教程
- 數(shù)據(jù)結(jié)構(gòu)案例教程(C/C++版)
- Java面向?qū)ο蟪绦蛟O(shè)計(jì)
- Illustrator CS6設(shè)計(jì)與應(yīng)用任務(wù)教程
- 監(jiān)控的藝術(shù):云原生時(shí)代的監(jiān)控框架
- Node.js區(qū)塊鏈開發(fā)
- Docker:容器與容器云(第2版)
- Groovy 2 Cookbook
- 算法精解:C語言描述