Install Python 3.12 on Windows; the installer also ships the py launcher
winget install Python.Python.3.12When using the official installer, tick Add python.exe to PATH or the python command will not exist
Configure Python: the Windows installer and py launcher, managing versions with pyenv or uv, virtual environments, pip mirrors, scaffolding and common error fixes.
Install Python 3.12 on Windows; the installer also ships the py launcher
winget install Python.Python.3.12When using the official installer, tick Add python.exe to PATH or the python command will not exist
Install a specific version plus the venv module via Homebrew on macOS or apt on Ubuntu
# macOS
brew install python@3.12
# Ubuntu / Debian
sudo apt update && sudo apt install -y python3.12 python3.12-venv python3-pipList every installed Python version and its path on Windows
py -0pWith multiple versions installed, pick one explicitly with py -3.11 or py -3.12
Install uv with pipx; uv manages Python versions, virtualenvs and dependencies much faster than pip
pip install --user pipx
pipx install uvInstall and list Python versions with uv, no admin rights required
uv python install 3.12
uv python listSwitch pip to the Tsinghua mirror globally and confirm the config
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config listUse a mirror for this install only without touching global config
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/Trust the host when an intranet mirror uses HTTP or a self-signed certificate
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cnRoute pip through a proxy with environment variables on macOS/Linux; use set on Windows
export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890uv accepts an index URL per install; set UV_INDEX_URL to apply it globally
uv pip install requests --index-url https://pypi.tuna.tsinghua.edu.cn/simpleCreate and activate a project-local virtualenv so global packages stay clean
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activateUse one .venv per project and add .venv/ to .gitignore
Confirm which interpreter the shell uses; after activation it should point into .venv
where python
# macOS / Linux
which python3Enable UTF-8 mode to avoid mojibake when reading and writing Chinese text on Windows
# Windows PowerShell(永久)
[Environment]::SetEnvironmentVariable("PYTHONUTF8", "1", "User")
# macOS / Linux
echo 'export PYTHONUTF8=1' >> ~/.zshrcLeave the current virtualenv and return to the system interpreter
deactivateVerify the interpreter and pip point to the same environment, then list installed packages
python --version
pip --version
pip listCreate a minimal project, install a dependency and verify the import works
mkdir demo && cd demo
python -m venv .venv
pip install requests
python -c "import requests; print(requests.__version__)"Export and restore the dependency list for handover and deployment
pip freeze > requirements.txt
pip install -r requirements.txtInit a project, add dependencies and run with uv without activating a virtualenv manually
uv init demo
cd demo
uv add requests
uv run main.pySpin up a throwaway static server to preview generated pages
python -m http.server 8000Install the Python extension, Pylance and Ruff for formatting and linting
code --install-extension ms-python.python
code --install-extension ms-python.vscode-pylance
code --install-extension charliermarsh.ruffInstall formatter and type checker CLIs so CI can run the same checks
pip install ruff black mypyInstall and start JupyterLab when you need interactive analysis
pip install jupyterlab
jupyter labAllow local scripts when PowerShell blocks Activate.ps1, then activate the virtualenv again
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserUpgrade pip through python -m pip so it lands in the right environment
python -m pip install --upgrade pipUpgrade the build toolchain before retrying when packages with native code fail to build
pip install --upgrade pip setuptools wheelWork through the interpreters visible on PATH when you hit command not found
where python3
where pyClear the pip cache when downloads are corrupt or disk usage is too high
pip cache purgeCheck for version conflicts among installed dependencies
pip checkThis website uses cookies to ensure you get the best experience on our website. Privacy Policy.