All you need to do is run

pip install /opt/mypackage

and pip will search /opt/mypackage for a setup.py or pyproject.toml, build a wheel, then install it.

The problem with using the -e flag for pip install as suggested in the comments and this answer is that this requires that the original source directory stay in place for as long as you want to use the module. It's great if you're a developer working on the source, but if you're just trying to install a package, it's the wrong choice.

Alternatively, you don't even need to download the repo from Github first. pip supports installing directly from VCS (version control systems) repos like git using a variety of protocols including HTTP, HTTPS, and SSH, among others. See the docs for examples.

To see all of the pip install command options, run

pip install --help
Answer from MattDMo on Stack Overflow
Top answer
1 of 3
226

All you need to do is run

pip install /opt/mypackage

and pip will search /opt/mypackage for a setup.py or pyproject.toml, build a wheel, then install it.

The problem with using the -e flag for pip install as suggested in the comments and this answer is that this requires that the original source directory stay in place for as long as you want to use the module. It's great if you're a developer working on the source, but if you're just trying to install a package, it's the wrong choice.

Alternatively, you don't even need to download the repo from Github first. pip supports installing directly from VCS (version control systems) repos like git using a variety of protocols including HTTP, HTTPS, and SSH, among others. See the docs for examples.

To see all of the pip install command options, run

pip install --help
2 of 3
54

You were looking for help on installations with pip. You can find it with the following command:

pip install --help

Running pip install -e /path/to/package installs the package in a way, that you can edit the package, and when a new import call looks for it, it will import the edited package code. This can be very useful for package development. Only use the -e flag if you need to edit the package's source code.

Further information about local installs and the -e/--editable flag of pip and its caveats is available in the official pip "Local project installs" and setuptools "Development Mode (a.k.a. "Editable Installs)" documentation chapters. The latter also lists a range of limitations of editable installs.

🌐
pip
pip.pypa.io › en › stable › cli › pip_install
pip install - pip documentation v26.0.1
Local or remote source archives. pip also supports installing from “requirements files”, which provide an easy way to specify a whole environment to be installed. ... Identify the base requirements. The user supplied arguments are processed here. Resolve dependencies. What will be installed is determined here. Build wheels. All the dependencies that can be are built into wheels. Install the packages (and uninstall anything being upgraded/replaced).
Discussions

Installing Python packages from local file system folder to virtualenv with pip - Stack Overflow
Is it possible to install packages using pip from the local filesystem? I have run python setup.py sdist for my package, which has created the appropriate tar.gz file. This file is stored on my sy... More on stackoverflow.com
🌐 stackoverflow.com
Where do i store my python package locally if i want to access it from anywhere?
One way is to use pip to install your package; cd myproject python3 -m pip install . You may need to create a pyproject.toml: https://www.scivision.dev/python-minimal-package/ These modules, setuptools and wheel, are useful. https://packaging.python.org/en/latest/tutorials/installing-packages/#ensure-pip-setuptools-and-wheel-are-up-to-date More on reddit.com
🌐 r/learnpython
7
3
January 18, 2023
software - What is the simplest way to do a user-local install of a python package? - Computational Science Stack Exchange
Python (as of 2.6 and 3.0) now ... for local installs, which do not require administrative privileges to install, so you just need to point your installer to that directory. If you have already downloaded the package foo and would like to install it manually, type: ... The following answer is provided for historical purposes: It's a little more work if you are using pip to download ... More on scicomp.stackexchange.com
🌐 scicomp.stackexchange.com
August 3, 2012
How does `pip install -e` work? Is there a specific file it looks for and installs from that? What does it do when you give it no arguments?
pip install is a command that takes a package and install it inside the site-packages folder of your Python installation (be it your main/system wide Python installation, or one inside a virtual environment). Normally, when you do this by simply writing a package name, like with pip install requests, pip looks for the package in the Python Package Index, or PyPI , which is a website. However, pip can also look for packages which are in other places (including inside your computer right now), and properly copy them to your site-packages folder. This is useful in a few specific cases: If you download the source code directly, i.e. from a github repository or another similar platform, you can use pip install to install this package without having to resort to PyPI. Now granted this is not very useful, since most people who create good packages and share them in github will also add them to PyPI anyways, but the option is there. Install a specific version of a package which is not directly available through PyPI, but may be reachable through github and others. Think about a unstable/dev build of a project: the devs don't want to make it available through PyPI to keep unaware users from downloading broken code, but you can pip install to install it as a Python package anyways, at your own risk. Install your own code as a package in your own machine. This basically copies your code over to the site-packages folder and treats it like any other package you've downloaded. Useful for testing and developing, since this makes your package behave like it would in any other system once you release it to the world. This is where pip install . comes into play: the dot is an actual argument, replacing the directory you're currently in. Most of the time you'll pip install your own packages using a terminal already inside of the project's folder, which is why you see the dot as sort of a default argument. Also keep in mind that you will some specific files in order for your package to be "installable", like a setup.py and possibly some __init.py__. Last thing to note is that pip install will install the current package as it is right now. If you pip install a package you're developing and add some new files to it afterwards, these changes will not be reflected on the actual package installed beforehand. To avoid having to pip install the package again and again after each change, you can pass the -e flag to make an editable install; in this case, changes to your files inside the project folder will automatically reflect in changes on your installed package in the site-packages folder. More on reddit.com
🌐 r/learnpython
7
10
March 8, 2019
🌐
pip
pip.pypa.io › en › stable › topics › local-project-installs
Local project installs - pip documentation v26.0.1
This will install the project into the Python that pip is associated with, in a manner similar to how it would actually be installed. This is what should be used in CI system and for deployments, since it most closely mirrors how a package would get installed if you build a distribution and installed from it (because that’s exactly what it does). You can install local projects in “editable” mode:
🌐
Betterscientificsoftware
betterscientificsoftware.github.io › python-for-hpc › tutorials › python-pypi-packaging
Python: Creating a pip installable package - Python for HPC: Community Materials
It is the most common way to install Python packages. E.g. ... The package can now be imported in Python scripts. You may need to run as sudo if you have root privileges, or append --user to install under your home directory (often this will be under $HOME/.local).
🌐
Texas Tech K-12
depts.ttu.edu › hpcc › userguides › application_guides › python.packages.local_installation.php
Installing Python packages locally | User Guides | High Performance Computing Center | Texas Tech
In order to bypass the need for root access you can instuct pip to instead install to your HOME folder by adding the --user option as shown below: ... Easy_install is another commonly used tool for installing Python packages and is a supported method for the installation of many packages.
Find elsewhere
🌐
Python Packaging
packaging.python.org › tutorials › installing-packages
Installing Packages — Python Packaging User Guide
Be cautious if you’re using a Python install that’s managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state. You can use python get-pip.py --prefix=/usr/local/ to install in /usr/local ...
🌐
Reddit
reddit.com › r/learnpython › where do i store my python package locally if i want to access it from anywhere?
r/learnpython on Reddit: Where do i store my python package locally if i want to access it from anywhere?
January 18, 2023 -

Im relatively new to python programming professionally (just over a year now) and i am at a point where i have code i have made that i want to use elsewhere. If i copy and paste the functions/classes, then any changes i make to them id need to make to them all. I understand the proper way of doing this is by making it a package.

I have made my code into a package, which i have working. But at the moment that package folder has to be in the save folder as the code im writing.

After some googling, ive found that you put them in the folder: /Library/Frameworks/Python.framework/Versions/3.9/lib

When i put it here, i still cant access it?

I am on mac os

I ran which python3 which is where i got the above path...

Any help would be great :)

🌐
IBM
ibm.com › support › pages › how-install-python-package-local-directory-using-pip-command
How to install python package from local directory by using pip command
!pip install -find-links=/project_data/data_asset confluent-kafka-2.0.2.tar.gz ... Looking in links: ind-links=/project_data/data_asset Processing ./confluent-kafka-2.0.2.tar.gz Preparing metadata (setup.py) ... done Building wheels for collected packages: confluent-kafka Building wheel for confluent-kafka (setup.py) ...
🌐
Python Land
python.land › home › virtual environments and package management › pip install: how to install and remove python packages
Pip Install: How To Install and Remove Python Packages • Python Land Tutorial
September 16, 2025 - Let’s see what pip has to say about this option: pip install --help .. -e, --editable Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url.
🌐
Nesi
nesi.github.io › hpc_training › lessons › maui-and-mahuika › installing-packages-locally
Installing packages locally (Python and R)
To install Python package pnumpy locally, type · pip install pnumpy --user · The package will then be downloaded, built, including dependencies, and installed under $HOME/.local. Make sure to have R loaded, e.g., module load R/3.5.0-gimkl-2017a · Then in R, type ·
🌐
Medium
medium.com › @roylowrance › how-i-create-local-python-packages-2f528ef57346
How I Create Local Python Packages | by Roy Lowrance | Medium
March 20, 2025 - The pip install command is used to install Python packages from PyPI, the global Python package index, and other sources, including your local project directory.
Top answer
1 of 4
4

Weirdly enough, on Debian and Devuan the --prefix needed to target /usr/local is /usr.

Meanwhile, --prefix=/usr/local installs to /usr/local/local/bin ¯\_(ツ)_/¯

This:

pip install --prefix=/usr awscli

produces the desired outcome, namely:

  • executable /usr/local/bin/aws,
  • python -c 'import botocore' working,
  • for all users of the container image.

Caveats

You'd best be sure you can guarantee the intersection of apt-installed and pip-installed python packages is, and will be, empty.

This is because both /usr and /usr/local form one "python installation"; the interpreter sees packages installed in both. (apt ones in /usr; pip ones in /usr/local).

Thus in PEP-668 terms, package shadowing may occur:

  • system tool foo depends on common == 1.*;
  • you pip-install bar that pulls in common >= 2.0;
  • system tool foo is now broken, because common v1 has been shadowed.
2 of 4
2

To summarize the generic advice pertaining to this issue.

1. Use apt package if possible

For simple needs, you might not actually need pip.

As an example, (some version of) requests can be installed with

sudo apt install python3-requests

2. Use venv, virtual environment

It's rather simple to spin up a dedicated "python installation" a.k.a. venv with completely isolated set of packages.

#-- ensure the dependency module is there
sudo apt install python3-venv

#-- create a venv at path ./my-shiny-awesome-sandbox/
python3 -m venv my-shiny-awesome-sandbox

#-- activate it in this shell session
source my-shiny-awesome-sandbox/bin/activate

pip list #-- empty
pip install .... #-- installs to ./my-shiny-awesome-sandbox

Then you don't have to worry about interactions with system packages.

Instead, you worry about maintaining & activating the venv.

3. Use pipx

sudo apt install pipx
pipx run pycowsay moo

This conceptually maintains an implicit hidden venv.

Because pipx is oriented at apps (console_scripts entry points), it's not trivial to install libraries with it, that you could import in your own scripts.

4. Say --break-system-packages

sudo pip install --break-system-packages awscli

This will install to /usr/local. You'll get both the entrypoint scripts, and the libraries.

A caveat is, you run the risk of intermixing apt packages with pip ones, if not careful. That's why the option name is intentionally scary.

🌐
Sentry
sentry.io › sentry answers › python › install python packages from a local package index
Install Python packages from a local package index | Sentry
Assuming we want to install the requests package from a local package index stored in /opt/pythonpackages, we can run this command: pip install requests --no-index --find-links file:///opt/pythonpackages
🌐
ActiveState
activestate.com › home › resources › quick read › how to manually install python packages
How to Manually Install Python Packages - ActiveState
January 24, 2024 - ... Pip is installed by default ... like ActivePython, which includes pip, or manually installing pip with get-pip.py: Download get-pip.py....
🌐
Ohio Supercomputer Center
osc.edu › resources › getting_started › howto › howto_install_your_own_python_modules
HOWTO: Install Python packages from source | Ohio Supercomputer Center
March 12, 2025 - This step may vary a bit, depending on the package you are compiling. You can execute python setup.py --help to see what options are available. Since we are overriding the install path to one that we can write to and that fits our management plan, we need to use the --prefix option. NumExpr build also requires us to set the PYTHONPATH variable before building: export PYTHONPATH=$PYTHONPATH:~/local/numexpr/2.8.4/lib/python3.6/site-packages
🌐
Medium
medium.com › full-stack-engineer › install-a-local-python-package-7fe4739ae049
How To Install a Local Python Package | Full Stack Wizardry
April 13, 2025 - Here’s how you can get around it with editable installs. 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. Navigate to your local package in the terminal and run the following command: ... Save this and move on to step 2. If you’re using base pip ...
🌐
W3Schools
w3schools.com › python › python_pip.asp
Python PIP
Open the command line interface and tell PIP to download the package you want. Navigate your command line to the location of Python's script directory, and type the following: ... Now you have downloaded and installed your first package!