Published
- 1 min read
Virtual Environments for Python Development
🐍 Python Virtual Environments
Python virtual environments are important because they allow you to isolate your project dependencies. This means you can have different versions of the same package for different projects, without any conflicts. This is especially useful when you’re working on multiple projects with different requirements.
Here are some aliases and functions I use for managing Python virtual environments:
createvenv
: This alias creates a new Python virtual environment in the.venv
directory and activates it. Command:python3 -m venv .venv && source .venv/bin/activate
Functions
pyenv-list
: Lists all available Python versions that can be installed with pyenv. Command:pyenv install --list
pyenv-install-310
: Sets the local Python version for the current directory to 3.10.12 using pyenv. Command:pyenv local 3.10.12
Remember to deactivate your virtual environment when you’re done working on your project. You can do this by simply typing deactivate
in your terminal.