layout | title | description |
---|---|---|
default |
Windows Setup |
Instructions for setting up on Windows |
WSL (Windows Subsystem for Linux) allows you to use Linux on top of Windows 10 natively, WSL2 is the most recent version of WSL and it is more stable. If you already have WSL(1), it is easy to convert to WSL2 (see Instructions to convert WSL(1) to WSL2), if your Windows 10 is patched with 1909 or older, see Install WSL2 on Windows 10 1909 or older.
-
Open Start (Win key) and search for Command Prompt (type directly) in your applications, right click and select
Run as administrator
. SelectYes
on the prompt that appears asking if you want to allow the app to make changes to your device. -
Type the following into the Command Prompt and then press
Enter
:wsl --install
-
Restart your computer to finish the WSL installation and continue with the Linux distro setup.
-
Open Start (Win key) and search for Command Prompt (type directly) in your applications, right click and select
Run as administrator
. SelectYes
on the prompt that appears asking if you want to allow the app to make changes to your device. -
Type the following command to view a list of available WSL distros you can install on Windows 10 and press Enter:
wsl --list --online
-
Type the following command to install the WSL with a specific distro (Ubuntu-18.04 recommended) and press Enter (it will start the distro if it has already been installed):
wsl --install -d <DISTRO-NAME>
-
Restart your computer, open Start (Win key) and search for Ubuntu, right click on Ubuntu <DISTRO-NAME> (18.04.5) on Windows (App) and you are supposed to have the WSL2 Ubuntu 18.04 terminal open. Now, you are ready to rock!
-
You will be prompted to
Enter new UNIX username
(This will create a local user account and you will be automatically logged in to <DISTRO-NAME> as this user), you can use any combination of alphanumeric characters here for your username, but a good choice is<first_initial><last_name>
(e.g.,jsmith
for John Smith), You will then be prompted to enter a new password(Choose something easy to remember as you will find yourself using it frequently.).
From this point on whenever the instructions specify to "open/type a command in a terminal" please assume you are supposed to open/type the command in the Ubuntu application (Open Start (Win key) and search for Ubuntu, right click on Ubuntu <DISTRO-NAME> (18.04.5) on Windows (App)).
You already have it, now that you’ve installed the WSL2!
You already have it, now that you’ve installed the WSL2!
- Go to this page and click the download button, then run the
.exe
file. - Leave all the defaults during the installation with the following exception:
- Please make sure the box labelled "Register Code as an editor for supported file types" is selected
These extentions will allow you to work with the WSL2 Ubuntu with GUI.
- Open the VSCode application, go to Extentions tab (on the left) and search for
Remote - WSL
orVSCode Terminal For Ubuntu
, install them; (Usually, VSCode can detect your WSL Ubuntu installation and remind you to install these related extentions). - Type
code .
into the terminal (Ubuntu <DISTRO-NAME> (18.04.5) on Windows (App)) and pressEnter
. You should see a message reading "Installing VS Code Server" and then a new VSCode window (entitled: Get Started - <USER NAME> [WSL: Ubuntu <DISTRO-NAME>] - Visual Studio Code) will open up. - Press
Ctrl+Shift+P
in the new VSCode window and type "Extensions: Install extensions" into the search bar that appears at the top of the screen, select the one that reads "Extensions: Install extensions". - A new panel should appear on the left-hand side of the screen with a search bar.
Search for each of the following extensions and press
Install in WSL: Ubuntu-\<DISTRO-NAME\>
for the first entry that appears. (The author listed for all of these extensions should be "Microsoft".)- Python Extension Pack (n.b., you will need to reload VSCode after installing this)
- Live Share (n.b., you may need to press "Ctrl/Cmd+Shift+P" and type "install extensions" again after installing this)
- Live Share Extension Pack
- Docker
- Remote - WSL
We are going to install miniconda to manage the python environment in our WSL2 Ubuntu using the VSCode terminal (at the bottom of the VSCode main window, working with this terminal is equavalent to ssh to the WSL2 Ubuntu) or the WSL Ubuntu terminal (Open Start (Win key) and search for Ubuntu, right click on Ubuntu <DISTRO-NAME> (18.04.5) on Windows (App)).
-
Type the following lines (separately) into the terminal and press
Enter
after each one:wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh
-
A license agreement will be displayed and the bottom of the terminal will read
--More--
. PressEnter
or the space bar until you are prompted with "Do you accept the license terms? [yes|no]." Typeyes
and then pressEnter
-
The installation script will inform you that it is going to install into a default directory (e.g.,
/home/$USER/miniconda3
). Leave this default and pressEnter
. -
When you are asked "Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no]," type
yes
and pressEnter
. Exit (or re-open) the terminal once the installation has finished. -
Re-open the Ubuntu application. Type
which python
into the terminal and it should return a path (e.g.,/home/$USER/miniconda3/bin/python
).- If you do not see a path like this then please try
cd miniconda3/bin/
then./conda init
, close (or re-open) your terminal, and repeat this step. If your issue is still not resolved skip the following step and contact an instructor on the #help-installation channel on the BHS Slack.
- If you do not see a path like this then please try
-
Type the following to remove the installation script that was downloaded:
rm ./Miniconda3-latest-Linux-x86_64.sh
Open a terminal and type the following commands:
conda config --append channels conda-forge
conda config --set channel_priority strict
conda create -n qlsc612 -y python=3.9 flake8 ipython jupyter jupyterlab matplotlib nibabel nilearn numpy pandas scipy seaborn bokeh
conda activate qlsc612
This installation step will take some time. These commands simply create a new conda python 3.9 environment named qlsc612 with all the nessesary packages installed for this course, conda activate qlsc612
will active this python environment (defaut env is base). Now you are ready to use VSCode to edit your python script or jupyter notebook in your WSL2 Ubuntu distribution.
Reminders:
- You may need to activate qlsc612 each time you start the WSL2 (VSCode) with
conda activate qlsc612
, if you want to keep qlsc612 the defaut choice for python environment, add this line to the end of${HOME}/.bashrc
and runsource ${HOME}/.bashrc
; - You still need to specify the python environment/kernel when you run jupyter notebook in VSCode (remote access to your WSL2 Ubuntu), click the button on top right of the jupyter notebook (there might be some texts on it like: base (Python 3.9.x)), VSCode will give you several options (usually 4) and choose qlsc612 (Python 3.9.x) miniconda3/envs/qlsc612/bin/python, it will then appear on the button (qlsc612 (Python 3.9.x)). This is the python environment we have just created for this course, make sure it is the one you are using for latter experiments.
You are supposed to install Docker Desktop after you have successfully installed WSL2.
- Download the Download Docker Desktop for Windows.
- Double-click Docker Desktop Installer.exe to run the installer.
- When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected or not depending on your choice of backend.
- Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
- When the installation is successful, click Close to complete the installation process. (If your admin account is different to your user account, you must add the user to the docker-users group. Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Log out and log back in for the changes to take effect.)
- Open Start (Win key) and search for Docker Desktop (type directly) in your applications, left click to
Run
. - You can always use docker comandline tools in Command Prompt or PowerShell.
The above step-by-step instructions are distilled from here. If you have questions during the installation procedure please check those links for potential answers!)