This project is for the personal setup of a new laptop for myself. This assumes an Intel Macbook Pro notebook. It has been heavily based on the setup guide used by Le Wagon for their bootcamps.
To setup you will have to do the following in the follwing order.
- Install Gitlab CLI
- Install the dotfiles
- Install XCode
- Install Homebrew and its extensions
- Install Visual Studio Code and its extensions
- Install Oh my zsh!
- Install Python, Jupyter and all their packages
- Install Docker
- Install DBeaver
First in order to login, copy-paste the following command in your terminal:
email
gh auth login -s 'user:email' -wgh will ask you few questions:
What is your preferred protocol for Git operations? With the arrows, choose SSH and press Enter. SSH is a protocol to log in using SSH keys
instead of the well known username/password pair.
Generate a new SSH key to add to your GitHub account? Press Enter to ask gh to generate the SSH keys for you.
If you already have SSH keys, you will see instead Upload your SSH public key to your GitHub account? With the arrows, select your public key
file path and press Enter.
Enter a passphrase for your new SSH key (Optional). Type something you want and that you'll remember. It's a password to protect your private
key stored on your hard drive. Then press Enter.
Title for your SSH key. You can leave it at the proposed "GitHub CLI", press Enter.
You will then get the following output:
! First copy your one-time code: 0EF9-D015
- Press Enter to open github.com in your browser...Select and copy the code (0EF9-D015 in the example), then press Enter.
Your browser will open and ask you to authorize GitHub CLI to use your GitHub account. Accept and wait a bit.
Come back to the terminal, press Enter again, and that's it.
To check that you are properly connected, type:
gh auth statusβοΈ If you get Logged in to github.com as <YOUR USERNAME> , then all good π
Open your terminal and run the following command:
export GITHUB_USERNAME=`gh api user | jq -r '.login'`
echo $GITHUB_USERNAMEYou should see your GitHub username printed. Time to fork the repo and clone it on your new laptop:
mkdir -p ~/code/$GITHUB_USERNAME && cd $_
gh repo fork pepearayao/dotfiles --cloneWe will install all of this in a later stage.
Open a new terminal, copy-paste the following command and hit Enter:
xcode-select --installIf you receive the following message, you can just skip this step and go to next step.
# command line tools are already installed, use "Software Update" to install updatesOtherwise, it will open a window asking you if you want to install some software: click on "Install" and wait.
βοΈ If you see the message "The software was installed" then all good π
β If the command xcode-select --install fails try again: sometimes the Apple servers are overloaded.
β If you see the message "Xcode is not currently available from the Software Update server", you need to update the software update catalog:
sudo softwareupdate --clear-catalogOnce this is done, you can try to install again.
On Mac, you need to install Homebrew which is a Package Manager. It will be used as soon as we need to install some software. To do so, open your Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"This will ask for your confirmation (hit Enter) and your macOS user account password (the one you use to log in when you reboot your Macbook).
π If you get a Error: Not a valid ref: refs/remotes/origin/master error
The full error would be:
Error: Not a valid ref: refs/remotes/origin/master :
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.Run the following commands to solve it:
rm -fr $(brew --repo homebrew/core) # because you can't `brew untap homebrew/core`
brew tap homebrew/coreIf you already have Homebrew, it will tell you so, that's fine, go on.
brew updateπ If you get a /usr/local must be writable error
Just run this:
sudo chown -R $USER:admin /usr/local
brew updateProceed running the following in the terminal (you can copy / paste all the lines at once).
brew upgrade git || brew install git
brew upgrade gh || brew install gh
brew upgrade wget || brew install wget
brew upgrade imagemagick || brew install imagemagick
brew upgrade jq || brew install jq
brew upgrade openssl || brew install openssl
brew upgrade tree || brew install tree
brew upgrade ncdu || brew install ncdu
brew upgrade xz || brew install xz
brew upgrade readline || brew install readlineLet's install Visual Studio Code text editor.
Copy (Cmd + C) the command below then paste it in your terminal (Cmd + V):
brew install --cask visual-studio-codeThen launch VS Code by running the following command in your terminal:
codeβοΈ If a VS Code window has just opened, you're good to go π
Let's install some useful extensions to VS Code.
code --install-extension ms-vscode.sublime-keybindings
code --install-extension emmanuelbeziat.vscode-great-icons
code --install-extension MS-vsliveshare.vsliveshare
code --install-extension ms-python.python
code --install-extension KevinRose.vsc-python-indent
code --install-extension ms-python.vscode-pylance
code --install-extension ms-toolsai.jupyterLet's install the zsh plugin Oh My Zsh.
In a terminal execute the following command:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"If asked "Do you want to change your default shell to zsh?", press Y
At the end your terminal should look like this:
direnv is a shell extension. It makes it easy to deal with per project environment variables. This will be useful in order to customize the behavior of your code.
brew install direnvRun the dotfiles installer.
cd ~/code/$GITHUB_USERNAME/dotfiles && zsh install.shCheck the emails registered with your GitHub Account. You'll need to pick one at the next step:
gh api user/emails | jq -r '.[].email'Run the git installer:
cd ~/code/$GITHUB_USERNAME/dotfiles && zsh git_setup.shβοΈ This will prompt you for your name (FirstName LastName) and your email. Be careful
you need to put one of the email listed above thanks to the previous gh api ... command. If you
don't do that, Kitt won't be able to track your progress.
Please now quit all your opened terminal windows.
Installing Python (with pyenv)
As we are using pyenv to install and manage our Python version, we need to uninstall conda, another package manager you may have on your machine if you previously installed Anaconda. Thus, we are preventing any possible Python version issue later.
Check if you have conda installed on your machine:
conda listIf you have zsh: command not found: conda, you can skip the uninstall of conda and jump to the Install pre-requisites section.
conda uninstall instructions
- Install the Anaconda-Clean package from your terminal and run the cleaning
conda install anaconda-clean
anaconda-clean --yes- Remove every Anaconda directories
rm -rf ~/anaconda2
rm -rf ~/anaconda3
rm -rf ~/.anaconda_backup
rm -rf ~/opt- Remove Anaconda path from your
.bash_profile- Open the file with
code ~/.bash_profile - If the file opens find the line matching the following pattern
export PATH="/path/to/anaconda3/bin:$PATH"and delete the line - Save the file with
CMD+s
- Open the file with
- Restart your terminal with
exec zsh - Remove Anaconda initialization from your
.zshrc:- Open the file with
code ~/.zshrc - Remove the code lines starting from
>>> conda initialize >>>to<<< conda initialize <<<
- Open the file with
Before installing Python, please check your xz version with:
brew info xzIt should be more than 5.2.0, if not you should run:
sudo rm -rf /usr/local/opt/xz
brew upgrade
brew install xzThen run:
brew install readlinemacOS comes with an outdated version of Python that we don't want to use. You might already have installed Anaconda or something else to tinker with Python and Data Science packages. All of this does not really matter as we are going to do a professional setup of Python where you'll be able to switch which version you want to use whenever you type python in the terminal.
First let's install pyenv with the following Terminal command:
brew install pyenv
exec zshLet's install the latest stable version of Python:
pyenv install 3.10.6π Troubleshooting
If you encounter an error installing Python with pyenv about zlib:
zipimport.ZipImportError: can't decompress data; zlib not availableInstall zlib with:
brew install zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"Then try to install Python again:
pyenv install 3.10.6It could raise another error about bzip2, you can ignore it and continue to the next step.
OK once this command is complete, we are going to tell the system to use this version of Python by default. This is done with:
pyenv global 3.10.6
exec zshTo check if this worked, run python --version. If you see 3.10.6, perfect! If not, ask a TA that will help you debug the problem thanks to pyenv versions and type -a python (python should be using the .pyenv/shims version first).
Before we start installing relevant Python packages, we will isolate the setup of the machine into a dedicated virtual environment. We will use a pyenv plugin called pyenv-virtualenv.
First let's install this plugin:
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
exec zshLet's create the virtual environment we are going to use during the whole bootcamp:
pyenv virtualenv 3.10.6 defaultLet's now set the virtual environment with:
pyenv global defaultGreat! Anytime we'll install Python package, we'll do it in that environment.
Now it's time to install some packages in it.
First, let's upgrade pip, the tool to install Python Packages from pypi.org. In the latest terminal where the virtualenv default is activated, run:
pip install --upgrade pipThen within the same folder, let's install some packages:
pip install -r requirements.txtImprove jupyter notebooks with extensions:
# install nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable toc2/main
jupyter nbextension enable collapsible_headings/main
jupyter nbextension enable spellchecker/main
jupyter nbextension enable code_prettify/code_prettifyImprove the display of the details disclosure elements in the notebooks.
Open custom/custom.css in the config directory:
cd $(jupyter --config-dir)
mkdir -p custom
touch custom/custom.css
code custom/custom.cssEdit custom.css with:
summary {
cursor: pointer;
display:list-item;
}
summary::marker {
font-size: 1em;
}Let's reset your terminal:
exec zshNow, check you can launch a notebook server on your machine:
jupyter notebookYour web browser should open on a jupyter window:
Click on New:
A tab should open on a new notebook:
Perform a sanity check for jupyter notebooks nbextensions. Click on Nbextensions:
Untick "disable configuration for nbextensions without explicit compatibility" then check that at least all nbextensions circled in red are enabled:
You can close your web browser then terminate the jupyter server with CTRL + C.
Check your Python version with the following commands:
zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh)" 3.10.6Run the following command to check if you successfully installed the required packages:
zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh)"Now run the following command to check if you can load these packages:
python -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py)"Make sure you can run Jupyter:
jupyter notebookAnd open a Python 3 notebook.
Make sure that you are running the correct python version in the notebook. Open a cell and run :
import sys; sys.versionHere you have it! A complete python virtual env with all the third-party packages you'll need for the whole bootcamp.
Download and install DBeaver, a free and open source powerful tool to connect to any database, explore the schema and even run SQL queries.
Docker is an open platform for developing, shipping, and running applications.
if you already have Docker installed on your machine please update with the latest version
Go to Docker website and choose Apple Intel:
Then follow the setup instructions, you are going to install a desktop application.






