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 venvActivate the Virtual Environment:
-
Windows:
venv\Scripts\activate
-
Unix or MacOS:
source venv/bin/activate
Deactivate the Virtual Environment:
deactivateUsing virtualenv
Install Virtualenv:
pip install virtualenvCreate a Virtual Environment:
virtualenv venvActivate and Deactivate:
Same as above.
Using conda
Create a Conda Environment:
conda create -n myenv python=3.9Activate the Conda Environment:
conda activate myenvDeactivate the Conda Environment:
conda deactivateUsing uv
Install UV:
pip install uvCreate a Virtual Environment:
uv venv venvActivate the Virtual Environment:
-
Windows:
venv\Scripts\activate
-
Unix or MacOS:
source venv/bin/activate
Deactivate the Virtual Environment:
deactivatePackage 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.gitUsing SSH:
pip install git+ssh://git@github.com/username/repository.gitSetting 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.gitNavigate to the Project Directory:
cd repositoryInstall in Editable Mode:
pip install -e .Git Commands
Basic Git Workflow
Initialize a New Git Repository:
git initClone an Existing Repository:
git clone https://github.com/username/repository.gitCheck Repository Status:
git statusAdd Changes to Staging Area:
git add filenameCommit Changes:
git commit -m "Commit message"Push Changes to Remote Repository:
git push origin branch_nameAdvanced Git Techniques
View Commit History:
git logSwitch to a Different Branch:
git checkout branch_nameCreate a New Branch and Switch to It:
git checkout -b new_branch_nameMerge Another Branch into Current Branch:
git merge branch_nameRebase Current Branch onto Another Branch:
git rebase branch_nameAdditional Commands
Pip Commands
List All Installed Packages:
pip listShow Package Details:
pip show package_nameFreeze Installed Packages to requirements.txt:
pip freeze > requirements.txtInstall Packages from requirements.txt:
pip install -r requirements.txtSearch for a Package on PyPI:
pip search package_name