MaruOpsInfrastructure and AI notes

About (Korean)Contact (Korean)

[Local LLM 08] Install Python and Create Project Environments

Laptop keyboard and trackpad

Reference photo · Laptop keyboard and trackpad · Photo: Scott Webb scottwebb / Source / CC0 · Resized for listings; illustrative photo, not the tested environment

Building a Local LLM · 08/30 · Development Environment

Full series and learning sequence · Practice code ZIP

When package installation succeeds but an import fails, inspect the Python interpreter running the program. It may differ from the interpreter used to install the package. Create a virtual environment inside the project and verify the executable path before adding dependencies.

Prepare the lab folder in Windows PowerShell. Once you’ve created a dedicated Python for your project, use the same path to install packages and run code.

Install Python runtime

Install Python Install Manager following the Windows instructions at python.org. Official distribution from the Microsoft Store is also available. The API examples in the series were written focusing on the standard library, and the runtime is set to Python 3.12 to consider compatibility with the ML library that will be used later.

pymanager install 3.12
py -V:3.12 --version
Get-Command python, py, pymanager -ErrorAction SilentlyContinue

The installation example uses pymanager to distinguish it from the existing py launcher. If you don’t find the command, open a new terminal and check the official documentation for conflict instructions. Before deleting your old Python, also check if it is being used by other projects.

Create a project-specific .venv

New-Item -ItemType Directory -Force "$env:USERPROFILE\local-llm-lab"
Set-Location "$env:USERPROFILE\local-llm-lab"
py -V:3.12 -m venv .venv
.\.venv\Scripts\python.exe -m pip --version
.\.venv\Scripts\python.exe -c "import sys; print(sys.executable)"

Make sure the last output points to python.exe under .venv in the current folder. The virtual environment is a directory that separately manages project packages. By default, it does not inherit any packages from your system Python. On another PC, it may be better to recreate the folder as a dependency list rather than copying it.

Direct execution of Python in virtual environment

Even if Activate.ps1 is blocked by the execution policy, Python in the virtual environment can be run. You can directly use the relative path to the executable file as shown below. We’ll do it that way in this series, so you don’t have to change your PowerShell policies.

.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip list
.\.venv\Scripts\python.exe -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:11434/api/version', timeout=10).read().decode())"

When adding a package, you can also use python -m pip to make it clear which Python you are installing to. We are not installing the requests or Ollama-specific SDKs yet. If you start with the request and response using the standard library, the scope to check when a problem occurs behind the scenes is reduced.

Dependencies and environment history

.\.venv\Scripts\python.exe -m pip freeze | Out-File -Encoding utf8 requirements.txt

Archive the source and requirements.txt and exclude files containing .venv and API keys from the repository. Also write down your Python version and Windows type. Freeze is a tool that leaves package versions, so it does not clone the operating system and drivers.

Labs conducted in user folders usually do not require administrator privileges. A blocked installation does not move all operations to the administrator terminal. In the next Node installation, we will continue the habit of checking the path to the executable file first.

reference material

Documentation and model tags checked: October 18, 2026. Primary lab environment: Windows 11 x64.