Tip
This post was translated by AI.
Installing pyenv #
Install pyenv, a Python version management tool.
Windows #
Open PowerShell with Administrator privileges and grant execution permissions.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachineInstall pyenv.
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"After installation, please restart PowerShell.
MacOS #
Install Homebrew, a package management tool.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Install pyenv.
brew install pyenvInstalling Python #
Install Python.
pyenv install 3.13You can change
3.13to any version you prefer.
Set the global Python version.
pyenv global 3.13Setting up venv Virtual Environment #
Navigate to your source code directory.
Specify the local Python version.
pyenv local 3.13Initialize the venv virtual environment.
python -m venv envActivate the virtual environment.
Windows
.\env\Scripts\Activate.ps1MacOS
source ./env/bin/activateIf a requirements.txt file exists, install the necessary packages.
python -m pip install -r requirements.txtThe virtual environment setup is now complete.