02-Getting-Started-Mac
Getting Started on Mac
Author: JeongHo Shin
Peer Review: JeongGi Park, Wooseok Jeong
Proofread : Q0211
This is a part of LangChain Open Tutorial
Overview
This guide provides a comprehensive setup process tailored for developing with LangChain on a Mac. LangChain is a framework for building applications powered by large language models (LLMs), and this guide ensures your environment is fully optimized for seamless integration and development.
Table of Contents
Opening Terminal
Open Spotlight Search by pressing Command + Space .
Search for terminal and press Enter to open the Terminal.
Installing Homebrew
Running the Homebrew Installation Command
Run the following command in the Terminal to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter your account password when prompted.
Press ENTER to proceed with the installation.
Configuring Homebrew Environment
Run the following command to check your username:
whoami

Check the installation path of Homebrew:
which brew
Verify the installation path of Homebrew:
Case 1 : If the output is /opt/homebrew/bin/brew , use the following command to configure the environment:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<your-username>/.zprofile
Case 2 : If the output is /usr/local/bin/brew , use the following command:
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> /Users/<your-username>/.zprofile
Verifying Xcode Installation
To check if Xcode Command Line Tools are installed, run the following command in your terminal:
xcode-select --install
Downloading Practice Code
[Reference] Practice code repository: LangChain Practice Code
Verifying Git Installation
Check if Git is installed by running the following command in your terminal:
git --version
If the command outputs the Git version, you already have Git installed, and no further action is required.
If Git is not installed, you can install it using Homebrew:
brew install git
After installation, verify Git again:
git --version
Downloading Practice Code with Git
Navigate to the Documents folder (or any other folder where you want to download the practice code). Use the following command:
cd Documents
If you want to use a different directory, replace Documents with your desired path.
Use the git command to download the practice code from the repository. Run the following command in your terminal:
git clone https://github.com/LangChain-OpenTutorial/LangChain-OpenTutorial.git

The repository will be cloned into a folder named LangChain-OpenTutorial within the selected directory.
Installing Pyenv
Reference
For detailed documentation, refer to the Pyenv GitHub Page.
Steps to Install Pyenv
Update Homebrew and install
pyenv
using the following commands:brew update brew install pyenv
Add the following lines to your ~/.zshrc file. Copy and paste the commands into your terminal:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init -)"' >> ~/.zshrc
If you encounter a permissions error, resolve it by running these commands:
sudo chown $USER ~/.zshrc echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init -)"' >> ~/.zshrc
Restart the terminal shell to apply the changes:
exec "$SHELL"
Installing Python
Use
pyenv
to install Python 3.11:pyenv install 3.11
Set Python 3.11 as the global Python version:
pyenv global 3.11
Restart the shell to ensure the changes take effect:
exec zsh
Verify the installed Python version:
python --version
Ensure the output shows 3.11.
Installing Poetry
Reference
For detailed documentation, refer to the Poetry Official Documentation.
Steps to Install and Configure Poetry
Install Poetry using
pip3
:pip3 install poetry
Set up a Python virtual environment using Poetry:
poetry shell
Update all Python dependencies in the project:
poetry update
Installing Visual Studio Code
Download Visual Studio Code:
Visit the Visual Studio Code Download Page.
Download the installer for your operating system.
Install Visual Studio Code:
Follow the installation instructions for your system.
Dag the application to the Applications folder.
Install Extensions:
Open Visual Studio Code.
Click on the Extensions icon on the left sidebar.
Search for "python" in the Extensions Marketplace and install it.
Search for "jupyter" in the Extensions Marketplace and install it.
Restart Visual Studio Code:
After installing the extensions, restart Visual Studio Code to apply the changes.
Select Python Environment:
Click on "Select Kernel" in the top-right corner of Visual Studio Code.
Choose the Python virtual environment you set up earlier.
Note: If your environment does not appear in the list, restart Visual Studio Code.
Now, Visual Studio Code is fully set up and ready for development with Python and Jupyter support.
Last updated