{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "
\n", " \n", " \"QuantEcon\"\n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Setting up Your Julia Environment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Contents\n", "\n", "- [Setting up Your Julia Environment](#Setting-up-Your-Julia-Environment) \n", " - [Overview](#Overview) \n", " - [A Note on Jupyter](#A-Note-on-Jupyter) \n", " - [Desktop Installation of Julia and Jupyter](#Desktop-Installation-of-Julia-and-Jupyter) \n", " - [Using Julia on the Web](#Using-Julia-on-the-Web) \n", " - [Installing Packages](#Installing-Packages) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview\n", "\n", "In this lecture we will cover how to get up and running with Julia.\n", "\n", "There are a few different options for using Julia, including a [local desktop installation](#jl-jupyterlocal) and [Jupyter hosted on the web](#jl-jupyterhub).\n", "\n", "If you have access to a web-based Jupyter and Julia setup, it is typically the most straightforward way to get started." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A Note on Jupyter\n", "\n", "Like Python and R, and unlike products such as Matlab and Stata, there is a looser connection between Julia as a programming language and Julia as a specific development environment.\n", "\n", "While you will eventually use other editors, there are some advantages to starting with the [Jupyter](http://jupyter.org/) environment while learning Julia.\n", "\n", "- The ability to mix formatted text (including mathematical expressions) and code in a single document. \n", "- Nicely formatted output including tables, figures, animation, video, etc. \n", "- Conversion tools to generate PDF slides, static HTML, etc. \n", "- [Online Jupyter](#jl-jupyterhub) may be available, and requires no installation. \n", "\n", "\n", "We’ll discuss the workflow on these features in the [next lecture](julia_environment.html).\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Desktop Installation of Julia and Jupyter\n", "\n", "If you want to install these tools locally on your machine\n", "\n", "- Download and install Julia, from [download page](http://julialang.org/downloads/) , accepting all default options. \n", " \n", " - We do **not** recommend [JuliaPro](https://juliacomputing.com/products/juliapro.html). \n", " \n", "\n", "\n", "\n", "\n", "- Open Julia, by either \n", " \n", " 1. Navigating to Julia through your menus or desktop icons (Windows, Mac), or \n", " 1. Opening a terminal and typing `julia` (Linux; to set this up on Mac, see end of section) \n", " \n", "\n", "\n", "You should now be looking at something like this\n", "\n", "\n", "\n", " \n", "This is called the JULIA *REPL* (Read-Evaluate-Print-Loop), which we discuss more [later](../more_julia/tools_editors.html#repl-main).\n", "\n", "- In the Julia REPL, hit `]` to enter package mode and then enter. " ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```julia\n", "add IJulia InstantiateFromURL\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This adds packages for\n", "\n", "- The `IJulia` kernel which links Julia to Jupyter (i.e., allows your browser to run Julia code, manage Julia packages, etc.). \n", "- The `InstantiateFromURL` which is a tool written by the QE team to manage package dependencies for the lectures. \n", "\n", "\n", "Note: To set up the Julia terminal command on Mac, open a terminal and run `sudo ln -s /Contents/Resources/julia/bin/julia /usr/local/bin/julia`.\n", "\n", "The full command might look like `sudo ln -s /Applications/Julia-1.3.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia`, if you placed the app in your `Applications` folder.\n", "\n", "**Note**: To obtain the full set of packages we use, at this stage you can run the following (see [the package setup section](#package-setup).)" ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```julia\n", "using InstantiateFromURL\n", "github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.5.0\", instantiate = true)\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Installing Jupyter\n", "\n", "If you have previously installed Jupyter (e.g., installing Anaconda Python by downloading the binary )\n", "then the `add IJulia` installs everything you need into your existing environment.\n", "\n", "Otherwise - or in addition - you can install it directly from the Julia REPL" ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```julia\n", "using IJulia; jupyterlab()\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Choose the default, `y` if asked to install Jupyter and then JupyterLab via Conda.\n", "\n", "After the installation, a JupyterLab tab should open in your browser.\n", "\n", "(Optional) To enable launching JupyterLab from a terminal, use [add Julia’s Jupyter to your path](julia_environment.html#add-jupyter-to-path).\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Starting Jupyter\n", "\n", "Next, let’s install the QuantEcon lecture notes to our machine and run them (for more details on the tools we’ll use, see our lecture on [version control](../more_julia/version_control.html)).\n", "\n", "1. Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git/). \n", "1. (**Optional, but strongly recommended**) Install the [GitHub Desktop](https://desktop.github.com/). " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### GitHub Desktop Approach\n", "\n", "After installing the Git Desktop application, click [this link](x-github-client://openRepo/https://github.com/QuantEcon/quantecon-notebooks-julia) on your desktop computer to automatically install the notebooks.\n", "\n", "It should open a window in the GitHub desktop app like this\n", "\n", "\n", "\n", " \n", "Choose a path you like and clone the repo.\n", "\n", "**Note:** the workflow will be easiest if you clone the repo to the default location relative to the home folder for your user.\n", "\n", "From a Julia REPL, start JupyterLab by executing" ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```julia\n", "using IJulia; jupyterlab()\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, if you installed Jupyter separately in [Jupyter Installation](#jupyter-installation) or [added Jupyter to your path](julia_environment.html#add-jupyter-to-path) then run `jupyter lab` in your terminal.\n", "\n", "Navigate to the location you stored the lecture notes, and open the [Interacting with Julia](julia_environment.html) notebook to explore this interface and start writing code." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Git Command Line Approach\n", "\n", "If you do not wish to install the GitHub Desktop, you can get the notebooks using the Git command-line tool.\n", "\n", "Open a new terminal session and run" ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```text\n", "git clone https://github.com/quantecon/quantecon-notebooks-julia\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This will download the repository with the notebooks in the working directory.\n", "\n", "Then, `cd` to that location in your Mac, Linux, or Windows PowerShell terminal" ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```text\n", "cd quantecon-notebooks-julia\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then, either using the `using IJulia; jupyterlab()` or execute `jupyter lab` within your shell.\n", "\n", "And open the [Interacting With Julia](julia_environment.html) lecture (the file `julia_environment.ipynb` in the list of notebooks in JupyterLab) to continue." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using Julia on the Web\n", "\n", "If you have access to an online Julia installation, it is the easiest way to get started.\n", "\n", "Eventually, you will want to do a [local installation](#jl-jupyterlocal) in order to use other\n", "[tools and editors](../more_julia/tools_editors.html) such as [Atom/Juno](http://junolab.org/), but\n", "don’t let the environment get in the way of learning the language.\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using Julia with JupyterHub\n", "\n", "If you have access to a web-based solution for Jupyter, then that is typically a straightforward option\n", "\n", "- Students: ask your department if these resources are available. \n", "- Universities and workgroups: email [contact@quantecon.org](mailto:contact@quantecon.org\") for\n", " help on setting up a shared JupyterHub instance with precompiled packages ready for these lecture notes. \n", "- [JuliaBox](http://www.juliabox.com) tightly controls allowed packages, and **does not** currently support the QuantEcon lectures. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Obtaining Notebooks\n", "\n", "Your first step is to get a copy of the notebooks in your JupyterHub environment.\n", "\n", "While you can individually download the notebooks from the website, the easiest way to access the notebooks is usually to clone the repository with Git into your JupyterHub environment.\n", "\n", "JupyterHub installations have different methods for cloning repositories, with which you can use the url for the notebooks repository: `https://github.com/QuantEcon/quantecon-notebooks-julia`.\n", "\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Installing Packages\n", "\n", "After you have some of the notebooks available, as in [above](#clone-lectures), these lectures depend on functionality (like packages for plotting, benchmarking, and statistics) that are not installed with every Jupyter installation on the web.\n", "\n", "If your online Jupyter does not come with QuantEcon packages pre-installed, you can install the `InstantiateFromURL` package, which is a tool written by the QE team to manage package dependencies for the lectures.\n", "\n", "To add this package, in an online Jupyter notebook run (typically with ``)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "hide-output": true }, "outputs": [], "source": [ "] add InstantiateFromURL" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then, run" ] }, { "cell_type": "markdown", "metadata": { "hide-output": false }, "source": [ "```julia\n", "using InstantiateFromURL\n", "github_project(\"QuantEcon/quantecon-notebooks-julia\", version = \"0.5.0\", instantiate = true)\n", "```\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If your online Jupyter environment does not have the packages pre-installed, it may take 15-20 minutes for your first QuantEcon notebook to run.\n", "\n", "After this step, open the downloaded [Interacting with Julia](julia_environment.html) notebook to begin writing code.\n", "\n", "If the QuantEcon notebooks do not work after this installation step, you may need to speak to the JupyterHub administrator." ] } ], "metadata": { "date": 1580349901.2836242, "download_nb": 1, "download_nb_path": "https://julia.quantecon.org/", "filename": "getting_started.rst", "filename_with_path": "getting_started_julia/getting_started", "kernelspec": { "display_name": "Julia 1.3.0", "language": "julia", "name": "julia-1.3" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.3.0" }, "title": "Setting up Your Julia Environment" }, "nbformat": 4, "nbformat_minor": 2 }