A handy guide for essential terminal commands used in development workflows. This README covers setting up virtual environments, managing packages, and performing common Git operations.
Virtual Environments
Isolating your development environment prevents conflicts between dependencies and makes managing packages easier. Below are commands for setting up virtual environments using different tools.
Using in-built venv
Create a Virtual Environment:
python -m venv venv
Activate the Virtual Environment:
-
Windows:
venv\Scripts\activate
-
Unix or MacOS:
source venv/bin/activate
Deactivate the Virtual Environment:
deactivate
Using virtualenv
Install Virtualenv:
pip install virtualenv
Create a Virtual Environment:
virtualenv venv
Activate and Deactivate:
Same as above.
Using conda
Create a Conda Environment:
conda create -n myenv python=3.9
Activate the Conda Environment:
conda activate myenv
Deactivate the Conda Environment:
conda deactivate
Using uv
Install UV:
pip install uv
Create a Virtual Environment:
uv venv venv
Activate the Virtual Environment:
-
Windows:
venv\Scripts\activate
-
Unix or MacOS:
source venv/bin/activate
Deactivate the Virtual Environment:
deactivate
Package Management
Installing the Latest Commit from a Git Repository
You can install the latest version of a package directly from a Git repository.
Using HTTPS:
pip install git+https://github.com/username/repository.git
Using SSH:
pip install git+ssh://git@github.com/username/repository.git
Setting Up Build from Source
For development purposes, you might want to install a package in editable mode to reflect changes in real-time.
Clone the Repository:
git clone https://github.com/username/repository.git
Navigate to the Project Directory:
cd repository
Install in Editable Mode:
pip install -e .
Git Commands
Basic Git Workflow
Initialize a New Git Repository:
git init
Clone an Existing Repository:
git clone https://github.com/username/repository.git
Check Repository Status:
git status
Add Changes to Staging Area:
git add filename
Commit Changes:
git commit -m "Commit message"
Push Changes to Remote Repository:
git push origin branch_name
Advanced Git Techniques
View Commit History:
git log
Switch to a Different Branch:
git checkout branch_name
Create a New Branch and Switch to It:
git checkout -b new_branch_name
Merge Another Branch into Current Branch:
git merge branch_name
Rebase Current Branch onto Another Branch:
git rebase branch_name
Additional Commands
Pip Commands
List All Installed Packages:
pip list
Show Package Details:
pip show package_name
Freeze Installed Packages to requirements.txt
:
pip freeze > requirements.txt
Install Packages from requirements.txt
:
pip install -r requirements.txt
Search for a Package on PyPI:
pip search package_name