Skip to content

Latest commit

 

History

History
153 lines (96 loc) · 8.06 KB

02c - Setup Local Development Environment on Mac.md

File metadata and controls

153 lines (96 loc) · 8.06 KB

Setup Local Development Environment on Mac OS

⏲️ Est. time to complete: 45 min. ⏲️

Here is what you will learn 🎯

You wil learn the following:

  • Installing Git
  • Installing Python
  • Installing Python Libraries
  • Setting up Python Virtual Environment
  • Installing Visual Studio Code

Table Of Contents

  1. Install Git
  2. Install Visual Studio Code
  3. Install Python
  4. Clone To-Do Application Repository
  5. Setup Python Virtual Environment
  6. Install Python Libraries

Depending on the operating system you are using, chose appropriate installation method below. For more details on Git and various installation refer to Install Git on GitHub

Install Git

Most versions of MacOS already have Git installed, and you can activate it through the terminal with git version. If you don't have Git installed, you can install the latest version using instructions below.

  • Navigate to the latest macOS Git Installer and download the latest version.
  • Once the installer has started, follow the instructions as provided until the installation is complete.
  • Open the command prompt "terminal" and type git version to verify Git was installed.

Note: git-scm is a popular and recommended resource for downloading Git on a Mac. The advantage of downloading Git from git-scm is that your download automatically starts with the latest version of Git. The download source is the same macOS Git Installer as referenced in the steps above.

Install Visual Studio Code

Follow the instructions below install VS Code on your computer. Visit Visual Studio Code download page to download latest version of installation package for your computer operating system.

  • Download VS Code installation package for Mac by clicking here
  • Go to the Downloads folder on Mac and double click on installation package to extract packages.
  • Move the Visual Studio Code application to the Application folder to make it available in the macOS launchpad.
  • Launch Visual Studio Code from Applications to make sure it is working as expected

Install Python

  • Download latest stable release of Python installation package for Mac by clicking here.
  • Once the download is complete, go to the download folder and double-click on the package file to start installing Python.
  • Click Continue and follow onscreen instructions to install Python. Once installation is completes, it opens Python folder.
  • To verify that the latest version of Python and IDLE installed correctly, double click on IDLE to show Python shell.
  • Review Python version in the shell to confirm Python is installed correctly.

Clone To-Do Application Repo

We now need to create a local copy of the To-Do Application repository that we created in an earlier step.

  1. From the To-Do Application repository on GitHub, click on the "Code" button and copy the link to the repository Clone Repo

  2. Open a terminal/console window. For windows users you can use the command prompt or powershell (i.e., "cmd.exe"). For Mac and Linux users you can use the terminal application.

  3. Navigate to the directory where you want to store the project

  4. Run the following command to clone the repository:

    git clone <link_to_this_repo>
  5. Navigate to the project directory:

    cd <project directory>

Setup Python Virtual Environment

  1. From the terminal window, navigate to the project directory

    cd <project directory>

    [!TIP] The repository for this training has a directory named myApplication that you can use as your default working directory while building the application or feel free to choose any directory where you would like to put this application.

  2. Copy the following requirements.txt file from Sprint 0 into your project directory.

  3. Open up Visual Studio Code in the project directory by executing the following command.

    code . 
  4. From Visual Studio Code, either select "View/Command Palette" or press Ctrl+Shift+P to open the command palette.

    Command Palette

  5. In the search box, type Python and then select the option Python: Create Environement... from the list of options.

    Create Environment

  6. An environment type selection box will appear. Select Venv Create a '.venv' environment in the current workspace from the list of options.

    Select Environment Type

  7. Select the Python interpreter version to use for the virtual environment. If you have multiple versions of Python installed, you should select the version that you installed in the previous step.

    Select Python Interpreter

  8. Check the box next to the requirements.txt file to install the required packages in the virtual environment and hit ok.

    Install Required Packages

  9. You will see a notification in the bottom right corner of the screen indicating that the virutal environment is being created. This can take a few minutes to complete.

    Virtual Environment Creation

  10. Once the virtual environment is created, you should see a notification in the bottom right corner of the screen indicating that the virtual environment has been created. This will create a new directory called .venv in the project directory that will contain the virtual environment. All python packages installed in this environment will be isolated from the global python environment.

  11. Open up a terminal window in Visual Studio Code and activate the virtual environment by running the following command.

    .venv\Scripts\Activate

    You should see the name of the virtual environment in the terminal prompt to indicate that the virtual environment is active.

Install Python Libraries

Code examples in some of the sprints uses following Python libraries. If these modules are not already installed, install these libraries by following the instructions below. Note however if you have already installed the virtual environment, you can skip this step as the libraries were installed as part of the virtual environment setup.

  1. Open Visual Studio Code if it is already not open

  2. Open Terminal window or Create a new terminal window in VS Code

  3. Make sure pip package manager installed in VS Code to install Python libraries. If not installed, follow the instructions below.

    • Download get-pip.py

    • Run below command in the VS Code terminal window

    python <Local folder path>\get-pip.py  
  4. Copy the following requirements.txt file from Sprint 0 into your project directory.

  5. Now, install the required libraries by running the following command in the terminal window:

    pip install requirements.txt

🔼 Sprint 0 - Home ◀ Previous setup step | Next Sprint ▶