Getting Started on Windows

Overview

This tutorial explains how to install the LangChain package on Windows environment. You can easily build a development environment by cloning the required github repository, batch installing the same packages as the author via pyenv, Poetry, installing Visual Studio Code and Jupyter Extension.

Table of Contents

References


Install git

Download git

Download 64-bit Git for Windows Setup

git-download

Confirm options during installation and proceed

Click the Next button for all the rest to proceed with the installation.

Window key - PowerShell must be run as administrator

Enter the command "git" and verify that the output looks like the image below

git
  • Apply PowerShell Policy

First, run Windows PowerShell as an "administrator."

Enter the following command to apply the policy

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

After the application is complete, turn Windows PowerShell off and then on. For the purposes of the following, "Run as administrator" when running Windows PowerShell.

Install pyenv

Install pyenv before installing python. pyenv installs a virtualization environment to prevent conflicts between packages.

git clone https://github.com/pyenv-win/pyenv-win.git "$env:USERPROFILE\.pyenv"
  • Add environment variables

Copy and paste the content below and run it

[System.Environment]::SetEnvironmentVariable('PYENV', $env:USERPROFILE + "\.pyenv\pyenv-win\", "User")
[System.Environment]::SetEnvironmentVariable('PYENV_ROOT', $env:USERPROFILE + "\.pyenv\pyenv-win\", "User")
[System.Environment]::SetEnvironmentVariable('PYENV_HOME', $env:USERPROFILE + "\.pyenv\pyenv-win\", "User")

Copy and paste the content below and run it

[System.Environment]::SetEnvironmentVariable('PATH', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('PATH', "User"), "User")

Shut down and rerun the current Windows PowerShell.

Enter the following command to verify that it works.

pyenv
  • Install python

Install Python version 3.11

pyenv install 3.11

Setting 3.11 version of python as the default runtime

pyenv global 3.11

Check your Python version

python --version

Make sure you have version 3.11.9 installed (or 3.11.11 is fine too!).

Install Poetry

Run the command below to install the Poetry package management tool.

pip3 install poetry

Navigate to the Documents folder.

cd ~/Documents

Execute the command below to get the source code.

git clone https://github.com/LangChain-OpenTutorial/LangChain-OpenTutorial.git

Execute the command below to navigate to the LangChain-OpenTutorial directory.

cd LangChain-OpenTutorial

Setting up a Python virtual environment

poetry shell

Batch update Python packages

poetry update

Install Visual Studio Code

Download Visual Studio Code

Install the downloaded Visual Studio Code (copy it to the Applications folder)

Click 'install' of Jupyter on left Menu of extensions

Install Jupyter Extension

Search for "python" and install

Search for "jupyter" and install

Turn off and restart Visual Studio Code

The installation is complete, and you can click the "select kernel" button in the top right corner.

Click python environment - if you don't see the virtual environment you installed, turn off Visual Studio Code and restart it

Last updated