This is the source repository for Quantitative Economics with Julia. These instructions required for authoring/editing the textbook and notebooks, and are not necessary for typical usage.
See LICENSE.md
for licensing and copyright information.
For information on releasing a new lecture version, see the docs.
- To get "Ubuntu on Windows" and other linux kernels see instructions.
- For the installation, run it in
Powershell
as an administrator - Hint on copy-paste: One way to paste into a a windows (of any sort) is the
<ctrl-c>
text somewhere else and then, while selected in the terminal at the cursor, to<right click>
the mouse (which pastes).
- For the installation, run it in
- Install VSCode and remote WSL support on windows
- Consider installing the shiny new Windows Terminal See VS Code Remote Editing and VS Code Remote WSL
In a windows terminal run
git config --global credential.helper wincred
In a WSL terminal,
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"
(see more details in Sharing Credentials )
To open the WSL in VS Code
- Click on the "><" icon on the bottom left hand corner, and open the remote folder in your WSL image (e.g.
~/lecture-source-jl
) - Choose "TERMINAL" to open a WSL terminal, and run any of the above jupinx or make commands.
-
Start within your home directory
-
Go to your home directory and make sure key dependencies are installed
cd ~
sudo sudo apt update
apt-get upgrade
sudo apt install make gcc unzip
sudo apt-get update
sudo apt-get install libxt6 libxrender1 libgl1-mesa-glx libqt5widgets5
-
Install Conda
- In the Ubuntu terminal, first install python/etc. tools
wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh bash Anaconda3-2020.02-Linux-x86_64.sh
- Create a directory
.conda
by runningmkdir ~/.conda
if the warning "Unable to register the environment" shows up
-
The installation will take time. You should:
- accept default paths
- accept licensing terms
- IMPORTANT Manually choose
yes
to have it do theconda init
- Delete the installation file
sudo pip install --upgrade --force-reinstall pyzmq rm Anaconda3-2020.02-Linux-x86_64.sh
-
Install Julia
wget -qO- https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.1-linux-x86_64.tar.gz | tar -xzv
- Assuming you installed anaconda in your home directory then,
- Within your home directory modify the
.bashrc
- Use VSCode Remote on Windows or
edit .bashrc
. This opens Vim. Go to the bottom of the file, and typei
to enter insert mode.
- Add something like the following:
export PATH=~/anaconda3/bin:~/julia-1.4.1/bin:$PATH
Hit <Esc>
to exit insert mode, and then type :x
to save and exit.
Then, from your terminal, run source .bashrc
to load the changes in the current WSL terminal.
- Install Jupinx and deps
conda upgrade conda
conda install dask distributed
pip install jupinx sphinxcontrib.bibtex jupinx guzzle_sphinx_theme
- Clone the repo to your preferred location (note that WSL+vscode+ssh cloning has bugs, so use https)
git clone https://github.com/QuantEcon/lecture-source-jl
Precompile the packages used by the lectures before building. To do this:
-
(Optional) Delete your
~/.julia
folder to start fresh. -
In a Julia REPL (i.e.
julia
in terminal if your.bashrc
was edited above), run
] add InstantiateFromURL IJulia; precompile
- Start a new REPL
(If you didn't run the package compilation step, then cd lecture-source-jl/source/rst
)
In the REPL, run
] activate .; instantiate; precompile
This will take a long time to run. You can safely ignore build errors for Electron
There are a few different targets, notably:
-
make website
, which will generate Jupyter, execute notebooks, and then turn that into HTML -
make coverage
, which will do steps (1) and (2) above (with otherwise hidden unit tests), and then generate a report about which notebooks fail. -
make preview
, which will do steps (1), (2), and (3) above and then fire up a local HTTP server. -
jupinx -w --files source/rst/getting_started_julia/julia_by_example.rst
, or any other.rst
for a single file
In vscode, the Live Server allows you to watch an output HTML file. Install the extension (in WSL if required) and after generating the HTML, right click on it and say "Open with Live Server"
Specifying parallel execution (i.e., make coverage parallel=8
) will use 8 cores instead of 1. This leads to a notable speedup in build times. (There are some zmq
errors that sporadically pop up at very high core counts, i.e. above 8.)
You can build only a few notebooks by jupinx -w --files source/rst/<file>.rst
.