Installing Julia and VS Code - A Comprehensive Guide
Fast-Track Your Julia Programming with VS Code
Table of contents
Julia is a relatively new, free, and open-source programming language. It has a syntax similar to that of other popular programming languages such as MATLAB and Python, but it boasts being able to achieve C-like speeds.
One popular IDE to use with Julia is Visual Studio Code, or VS Code.
In this post, we will learn how to install Julia and VS Code. We will also learn how to configure VS Code to get it to work with Julia.
The instructions for installing Julia and VS Code vary by operating system. Please use the table of contents to jump to the instructions that are relevant to you. Note that the instructions for configuring VS Code are the same for all operating systems.
Windows
Installing Julia
- Go to https://julialang.org/downloads.
In the table under the heading "Current stable release", go to the row labeled "Windows" and click the "64-bit (installer)" link. (Of course, click the 32-bit link if you have a 32-bit machine.)
(See Installing a Specific Julia Version for details on installing an older Julia version.)
- Run the installer.
Choose where to install Julia. (The default location works well unless you have a specific need to install Julia somewhere else.) Then click "Next".
Specify some additional options.
- "Create a Desktop shortcut": Allows you to run Julia by clicking the shortcut on your Desktop.
- "Create a Start Menu entry": Allows you to pin Julia to your Start Menu. Also allows you to easily search for Julia from the Start Menu.
- "Add Julia to PATH": (Recommended) Allows you to run Julia from the command line without specifying the full path to the Julia executable. Also enables easier integration with VS Code.
Then click "Next".
Installation is complete! Click "Finish" to exit the installer.
Running Julia
There are a few different ways to run Julia on Windows.
If you created a Desktop shortcut, you can double-click the shortcut to start Julia.
If you created a Start Menu entry, you can run Julia from the Start Menu. First search for "julia".
And then click on the appropriate result to start Julia.
- You can also run Julia
from the command line
(Command Prompt or PowerShell).
If Julia was added to PATH,
you can run
Otherwise, you can specify the full (or relative) path.C:\Users\user> julia
C:\Users\user> .\AppData\Local\Programs\Julia-1.9.3\bin\julia.exe
After starting Julia you will be greeted with a fresh Julia prompt.
Now you know how to install and run Julia on Windows!
Installing VS Code
- Go to https://code.visualstudio.com.
Click "Download for Windows".
- Run the installer.
Click "I accept the agreement" and then click "Next".
Choose where to install VS Code. (The default location works well unless you have a specific need to install VS Code somewhere else.) Then click "Next".
Specify the Start Menu folder for VS Code. (The default folder is fine.) Then click "Next".
Specify additional options if desired. (The defaults are fine, but if you want a Desktop shortcut be sure to select that option.) Then click "Next".
Click "Install".
Installation is complete! Click "Finish" to exit the installer.
Running VS Code
You can run VS Code using any of the methods described above for running Julia:
using the Desktop shortcut.
using the Start Menu.
- using the command line.
C:\Users\user> code
Now you know how to install and run VS Code on Windows!
Jump to Configuring VS Code for Julia to learn how to configure VS Code.
macOS
Installing Julia
- Go to https://julialang.org/downloads.
In the table under the heading "Current stable release", go to the rows labeled "MacOS" and click the "64-bit (.dmg)" link for either Apple Silicon or the Intel or Rosetta link for older machines or special scenarios.
(See Installing a Specific Julia Version for details on installing an older Julia version.)
Open the downloads folder and double-click on the Julia Disk Image you just downloaded.
In the new window, drag Julia into the Applications folder.
Allow Julia to be copied with your credentials or Touch ID.
Eject the disk image, either with the eject button or with right-click and selecting "Eject".
We recommend you follow these final instructions to make it easier to open Julia on your Mac. Open a new terminal window and follow these instructions:
sudo mkdir -p /usr/local/bin sudo rm -f /usr/local/bin/julia sudo ln -s /Applications/Julia-1.9.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia
Running Julia
You can start Julia through your normal means of opening applications
or through typing julia
into your terminal (if you did the last step above).
See Apple's support if you need help.
After starting Julia you will be greeted with a fresh Julia prompt.
Now you know how to install and run Julia on macOS!
Installing VS Code
- Go to https://code.visualstudio.com.
Click "Download Mac Universal".
Open the downloads folder and drag VSCode into the Applications folder.
Allow VSCode to be moved with your credentials or Touch ID.
You can start VS Code through your normal means of opening applications.
Now you know how to install and run VS Code on macOS!
Jump to Configuring VS Code for Julia to learn how to configure VS Code.
Linux
Installing Julia
- Go to https://julialang.org/downloads.
In the table under the heading "Current stable release", go to the row labeled "Generic Linux on x86" and click the "64-bit (glibc)" link. (This link should work for most Linux systems. If you have a different computer architecture, you probably already know to choose a different download link.)
(See Installing a Specific Julia Version for details on installing an older Julia version.)
- Open a terminal
and navigate to the directory
where you want to install Julia.
In this post,
we will install Julia
in
~/programs/julia/
. (Note that everything up to and including the$
is the terminal prompt, so the actual command to run is everything after the$
.)~$ mkdir -p ~/programs/julia ~$ cd ~/programs/julia
- Move the downloaded archive
to the current directory.
~/programs/julia$ mv ~/Downloads/julia-1.9.3-linux-x86_64.tar.gz .
- Unarchive the file.
~/programs/julia$ tar xzf julia-1.9.3-linux-x86_64.tar.gz
- Add Julia to your PATH
by adding the following
to your
.bashrc
or.zshrc
file. (Remember to change/home/user/programs/julia
to the directory where you installed Julia.)
(Restart the terminal to actually update the PATH.)export PATH="$PATH:/home/user/programs/julia/julia-1.9.3/bin"
Julia is now installed!
Running Julia
You can run Julia from the command line.
$ ~/programs/julia/julia-1.9.3/bin/julia
Or, if you added Julia to your PATH:
$ julia
After starting Julia you will be greeted with a fresh Julia prompt.
Now you know how to install and run Julia on Linux!
Installing VS Code
The following steps were tested on a computer running Ubuntu. They should work as written for any Debian-based Linux distribution, but modifications may be necessary for other Linux distributions. Note that you will need admin privileges for one of the steps below.
- Go to https://code.visualstudio.com.
Click "⤓ .deb".
- (Requires admin privileges)
Either open your file manager
and double-click the downloaded file,
or install VS Code
via the command line.
(Remember to change the file path/name as needed.)
$ sudo dpkg -i /home/user/Downloads/code_1.81.1-1691620686_amd64.deb
VS Code is now installed!
Running VS Code
You can run VS Code from the command line.
$ code
Now you know how to install and run VS Code on Linux!
Jump to Configuring VS Code for Julia to learn how to configure VS Code.
Installing a Specific Julia Version
If you need a specific version of Julia, you can navigate to the older releases page and find the appropriate installer for the version you need. For example, to install Julia 1.0.5 on Windows, you would find "v1.0.5" on the left column and then click on the download link to download the installer.
Otherwise, the installation instructions should be basically the same.
Configuring VS Code for Julia
After starting VS Code for the first time you will be greeted with "Get Started with VS Code".
Feel free to walk through the options, but for this post we will ignore them and just click "< Welcome" on the top left of the window. That brings us to the welcome page.
We need to install the Julia extension for VS Code.
Click on the extensions button.
Search for "julia". Click "install" on the Julia extension.
Now we need to make sure the Julia extension knows where Julia is installed. If you added Julia to PATH, this step can be skipped. However, if you get errors trying to run Julia in VS Code or if you find the wrong Julia version is being used (if you have multiple versions installed), you can follow these steps.
Open the Julia extension settings by clicking the settings icon. Click "Extension Settings".
Search for "executable path". Then type the path to the Julia executable in the "Julia: Executable Path" extension setting.
Now VS Code is ready for Julia development!
Developing Julia Code in VS Code
Click the file icon in the top left to open the Explorer pane. Then click "Open Folder".
- Navigate to a folder
(or create one)
where your Julia code will be saved.
In this post,
we created a folder called
Julia
. Click the "New File" button next to the folder in the Explorer pane. Then type a name for the file where you will write Julia code. It should have a
.jl
extension. In this post, we created a file calledscript.jl
.VS Code will now open a new tab with a blank file ready for us to edit.
- Add the following code to your file
and then save it.
println("Hello, World!")
To run the code, place your cursor on the line of code to execute and then press
Shift+Enter
. This command will start a Julia session (if one has not already been started) and then run the code. (The very first time you run code may take a little while because packages need to precompile.)Now add more lines of code.
function plus1(x) x + 1 end a = 3 b = plus1(a) b == a + 1
To run all the code in the file, open the command palette with
Ctrl+Shift+P
and search for "Julia: Execute active file in REPL". Highlight the command and pressEnter
.Note that two lines of output were added to the REPL: the
println
statement and the value ofb == a + 1
(the last line that was executed).Now that some code has run, we can look at the Julia pane on the left and see the variables and function we defined in the "Workspace" tab.
We can also use the REPL directly.
And now you know how to write and run Julia code in VS Code!
If you would like to see more tips and tricks for how to use Julia in VS Code, be sure to comment below!
Summary
In this post, we learned how to install Julia and VS Code on different operating systems. We also learned how to configure VS Code for developing Julia code.
Once you have installed Julia, move on to the next post to learn about variables and functions! Or, feel free to take a look at our other Julia tutorial posts!