Install a Local Python Package
How do you do an editable install of a local package in a Python project?

When I’m writing code, sometimes I encounter a problem I want to solve that is either unsolved or isn’t solved to my satisfaction. In these moments, I reach for Poetry, roll my own code, and make a new PyPi package.
Because this process starts with a problem in another codebase, it’s helpful to co-develop the package and my codebase. But pushing to PyPi and pulling a new version for every change is a massive pain. Here’s how you can get around it with editable installs.
Step 0 — Make Sure Your Code is a Valid Package
Your PyPi project must be in a PyPi-compatible format for this to work. By far, the easiest way to do this is to use Poetry:
Set up your new package using Poetry and proceed to the next step.
Step 1 — Get Your Local Packages Directory Path
Navigate to your local package in the terminal and run the following command:
pwd
You will see some output, for example:
C:\Users\Connor\Documents\Work\Projects\Open Source\ezprompt
Save this and move on to step 2.
Step 2 — Pip install it to your codebase
If you’re using base pip you can do this with the following command:
pip install -e "your/package/directory/path/here"
The -e option tells pip this package should be “editable”. In practice, this means pip points directly at your local package. So, any changes you make are immediately available in your codebase, massively simplifying the co-development cycle.
Install With Poetry
If you’re using Poetry for dependency management in your original codebase, then there’s one more initial step. Load the Poetry shell:
poetry shell
Once inside the virtual environment, run the same command as before:
pip install -e "your/package/directory/path/here"
This will not update your pyproject.toml but it will install the package into the base virtual environment created by Poetry.
Final Words
That’s it! I hope this saves you as much time as it does for me. If you have any questions, drop them in the chat. Now, go forth and write PyPi packages!
If you’re interested in how to go from Poetry to PyPi, you can read this: