Great question 👌 — pip install -e . is a very common command in Python development, especially when working on local projects or libraries.
🔍 What it means
-
pip install → tells pip to install a package.
-
-e (short for --editable) → tells pip to install the package in editable/development mode.
-
. → means “install the current directory” (where your setup.py or pyproject.toml file lives).
So, pip install -e . installs your project in editable mode from the current folder.
⚡ What actually happens
-
Normal install (without -e)
-
Pip builds your package (from setup.py / pyproject.toml).
-
Copies all files into your Python site-packages directory.
-
Any change in your local source files won’t affect the installed version — you’d need to reinstall.
-
-
Editable install (-e)
-
Instead of copying, pip creates a link (symlink or .egg-link) from site-packages back to your source directory.
-
Your project’s metadata (.egg-info or .dist-info) is still created in site-packages.
-
Now, when you import the package, Python loads directly from your source folder.
✅ This means any changes you make to the code locally are immediately reflected without reinstalling.
-
🛠 Typical use cases
-
Developing your own Python package and testing changes quickly.
-
Contributing to an open-source library and wanting to run it locally.
-
Avoiding repeated re-installation during active development.
📌 Example
Suppose your project looks like this:
myproject/
├── setup.py
├── pyproject.toml
└── mypackage/
└── __init__.py
Run:
pip install -e .
-
Your package mypackage is now importable anywhere (e.g., import mypackage).
-
Any edits you make to mypackage/__init__.py will be reflected immediately when you re-run Python.
👉 Would you like me to also explain how pip install -e . works with pyproject.toml-based projects (PEP 517/518) since many modern projects no longer use setup.py?
No comments:
Post a Comment