python -m venv <venv-name>
source <venv-name>/bin/activate
# If there is a requirements.txt file, install it
pip install -r requirements.txtCreate the new project using uv. Built using Rust and is faster that pip
uv init
# After following wizard create the virtual environment
uv venv
# Sync/Add/Remove dependencies
uv sync
uv add <dep-name>
uv remove <dep-name>
# Build the project
uv build
# Run the project
uv run main.pyThere are often times where we are forced to run old python scripts which require an older version of python to run. In this case NEVER remove the system python and install an older one. We use a python version manager for this.
# Locally install a different/older python version than the system python
uv python install <version-number>
# View available python versions to switch to for the curr. project
uv python list
# Switch to that version
uv python pin <version-number>- Set the global python version (not recommended)
pyenv global <version-number>- Inside base directory of the repo, check if current python version and pyenv version match
pyenv versions
python --versionIF they DON'T MATCH
# Check where pyenv lives
# If it's `~/.pyenv`, Go ahead. If not, fix it first.
pyenv rootRun these commands to add pyenv to your environment path
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
eval "$(pyenv init -)"
source ~/.bashrc # or ~/.zshrcNow check if the python versions match
which python # should show ~/.pyenv/shims/python
python --version
pyenv versionsAfter both commands give the same output
# Check python version for the current directory
pyenv local
# If desired version is not installed
pyenv install <version-number>
# Set the desired python version as the project python interpreter
pyenv local <version-number>
# Check if version is set
python --version