TODO
- Complet Install-Visual-Studio-Code
- Add advantage/disadvantage jupiter/vs code
- Add the setup : WSL, ect. so it can be used for this project
- Test
This guide will walk you through setting up a Jupyter Notebook on a machine using Mambaforge and WSL. And also install Visual Studio Code.
-
Install Windows Terminal:
- Download from the Windows Store (already installed on Windows 11).
-
Set up WSL:
- Run Windows Terminal as administrator and execute:
wsl --install
- Restart your computer, set up your Ubuntu user (username in small letters and password).
- Run Windows Terminal as administrator and execute:
-
Update Linux Distribution:
sudo apt-get update sudo apt-get install wget ca-certificates
- Set Ubuntu as Default Shell (optional):
- In Terminal settings, under Startup, set Ubuntu as the default profile to always start with the correct terminal.
- Check if Python is already installed:
which python
- If Python is present, you might want to uninstall it before proceeding.
- Download Mambaforge:
- Go to the Mambaforge GitHub page, find the appropriate Linux distribution that corresponds to the type of CPU (architecture) you are using, and copy the download link in the table.
[!IMPORTANT] Do not select an installer under Miniforge-pypy3 but Miniforge3.
-
Check the directory
pwd
Should return
/home/<username>
- Create a
downloads
folder
mkdir downloads
- Create a
-
Install Mambaforge:
wget <Miniforge3_download_link> bash <name_sh_file>.sh
- Agree to the terms, press
Enter
for default options, and typeyes
when prompted to initialize conda. - Restart terminal for Ubuntu, you should see
(base)
at the beginning of prompt.
- Agree to the terms, press
Note
Everytime you open a new Ubuntu terminal, you should see (base)
environment. That means your configuration setup works well for this course and labs.
- Ensure Mambaforge is correctly installed:
which python
- It should point to the Mambaforge directory :
home/<username>/miniforge3/bin/python
- It should point to the Mambaforge directory :
-
Install necessary packages:
mamba install ipython jupyterlab ipywidgets
- Accept prompts with
Y
.
- Accept prompts with
- Keep Mambaforge up to date:
mamba update mamba
- Set up the environment in Jupyter:
python3 -m ipykernel install --user --name=python3
- Launch JupyterLab:
jupyter lab --no-browser
- Use the provided link to access JupyterLab from your browser.
- Close JupyterLab:
- Close navigator and clic on ctrl+c on Terminal, the accept prompts with
Y
- Close navigator and clic on ctrl+c on Terminal, the accept prompts with
VS Code is a source-code editor, it include usefull features like debugging support, code completion, code refactoring, syntax highlighting and embedded git control.
Use this installation help to guide you through the VSCode installation and configuration with WSL, stop before the section Install Git (optional).
Go to Developing in WSL for more information about the installation and operation.
For working on a Notebook, the two methods works and have advantages, few difference between the two methods :
VS code | Jupyter | ||
---|---|---|---|
+ | - | + | - |
Can be set as we want | Must be configured correctly | Avoid setting conflict (folder where data are, etc) | Underdeveloped modules (black formatter, git, github copilot, etc.) |
Autocomplete | IDE easy to install | No autocomplete | |
Powerful modules |
Be sure git is installed correctly on your computer by following this quick tutorial.
In Ubuntu/WSL Terminal, follow the next steps :
- Set up your Git identity:
git config --global user.name "Your Name" git config --global user.email "your.name@example.ch"
- Confirm that the Git username is set correctly:
$ git config --global user.name > Your Name $ git config --global user.email > your.name@example.ch
-
Generate SSH Key:
ssh-keygen -t ed25519 -C "your_email@example.ch"
When you're prompted to "Enter a file in which to save the key", you can press Enter to accept the default file location, same for passphrase.
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
-
Add public SSH Key to GitHub:
- Copy the generate text in Terminal by the following command :
cat ~/.ssh/id_ed25519.pub
- Paste it into your GitHub account under Settings > SSH and GPG keys.
- Copy the generate text in Terminal by the following command :
-
Clone the project repository:
Create a folder (like git in exemple) and clone the repository inside
mkdir git cd git git clone git@github.com:heig-vd-ie/rht.git
Type
yes
to accept the warning.
- Install packages from
environment.yml
into the(base)
environnement:cd rht mamba env update -n base --file environment.yml
Commiting your work with Git
To add all the changes you've made:
git add .
To commit them:
git commit -m "MY MESSAGE HERE"
[!NOTE]
-m
is the message flag here. The message is really important in order for tracking your work via git.
You can also put those steps together like this:
git commit -a -m "MY MESSAGE HERE"
To push your committed changes from your local repository to your remote repository:
git push origin master
It is possible to get some type in your username/password for github. Unless you have configured SSH keys correctly..
More information about these steps:
[!IMPORTANT] You are done with the setup. If you did not get any trouble, you can continue with the tutorials for this course github.com's notebook viewer.
If you get many problems with your git branch or repo, please get in touch with Luca or Antoine.
This section is designed to help you solve problems before contacting support directly. Try one of the following steps, depending on which part of the guide is giving you trouble.
Installation automation (to optimize later on)
We are going to run the following script from the terminal setup-conda.sh
. Don't worry, we will guide you through the all process.
Go to your download folder by typing the following command in your terminal:
cd downloads
wget https://github.com/fastai/fastsetup/blob/master/setup-conda.sh
Then, you can type the following command into the terminal:
chmod u+x setup-conda.sh
In a nutshell, those commands help to change the permissions to add executable permission to the current user (yourself). Then type:
./setup-conda.sh
The installation is starting...
- Restart terminal for Ubuntu.
- You should see
(base)
at the beginning of prompt.
[!NOTE] Everytime you open a new Ubuntu terminal, you should see
(base)
environment. That means your configuration setup works well for this course and labs.
At this point, we have to check if your configuration works fine:
- Run
which python
, you should see that the python you are running is in the mambaforge directory:home/<username>/miniforge3/bin/python
on Linux/WSL and/Users/<username>/miniforge3/bin/python
. - This means everything was just setup correctly.
Only if you encounter difficulties with WSL
There is no need to enable 'Windows Subsystem for Linux' in the Turn Windows features on or off
settings unless you get in trouble with your installation setup. In such case, it is recommended to follow this tutorial or get back to assistance.
Only if you encounter difficulties with Mambaforge
rm -rf mambaforge
- Remove conda initializing commands from
\\wsl.localhost\Ubuntu\home\<username>
:.bashrc
file (with a text editor). Delete everything at the end of the script between these commands:
# >>> conda initialize >>>
__conda_setup=
...
# <<< conda initialize <<<
[!NOTE] Uncollapse these section depending where you need more help to solve troubleshootings.
Only if you encounter difficulties with GitHub
We regularly update the notebooks to fix issues and add support for new librarires. So make sure you update this project regularly.
For this, open a terminal, and run the following:
cd $HOME # or whatever development directory you chose earlier
cd rht # go to this project's directory
git pull
If you get an error, it's probably because you modified a notebook. In this case, before running git pull
you will first need to commit your changes. I recommend doing this in your own branch, or else you may get conflicts:
git checkout -b my_branch # you can use another branch name if you want
git add -u
git commit -m "Describe your changes here"
git checkout main
git pull
Next, let's update the libraries. First, let's update mamba
itself:
mamba update -c defaults -n base mamba
mamba activate base
jupyter lab --no-browser
References (not necessary to follow – backup)
[!NOTE] Notice that it is however using
conda install
, which we will replace withmamba install
.
[!WARNING] More information about it can be found here and here. Mambaforge (Discouraged as of September 2023), that means "the packages and configuration of Mambaforge and Miniforge3 are now identical. The only difference between the two is the name of the installer and, subsequently, the default installation directory."
- Beginner's Guide to Mambaforge Installation
- Mambaforge setup page
- Fastsetup script
- Jeremy Howard's Live Coding Sessions
- Mamba Installation
- Mamba Installation with Docker
- Miniforge3 23.3.1-0
- Windows Subsystem for Linux Documentation
- Open a WSL project in Visual Studio Code
- Open a remote folder or workspace
- Install Ubuntu on WSL2 and get started with graphical applications
- Install Ubuntu on WSL2 on Windows 10
- How to get access to your Linux (WSL) Files in Windows 10 or 11
- What're the differences between these 2 ways of launching WSL?
- Get started with Docker remote containers on WSL 2
- Advanced: Opening a WSL 2 folder in a container
- Get started tutorial for Python in VS Code
- Add User to WSL Linux Distro in Windows 10
- Switch user in WSL Linux Distro in Windows 10
- How to set default user, switch user, and remove a user for WSL
- Quickstart with GitHub
- What is a Git SSH Key?
- Checking for existing SSH keys
- Generating a new SSH key and adding it to the ssh-agent
- Generating a new SSH key for a hardware security key
- Adding a new SSH key to your GitHub account
- Multiple SSH Keys settings for different github account
- Working with SSH key passphrases
- About commit signature verification
- Do I need authentication as well as signing keys on GitHub?
- Connect to an existing JupyterLab server (with the link you just copied from your terminal session)
- The python requirements file and how to create it
- Conda install requirements
- Introducing the new JupyterLab Desktop!