How can I install a local Python package with extra components using pip?

841 Views Asked by At

pip supports installing extra components while installing a Python package from internet, e.g.,

pip install dask[all]
pip install "dask[all] @ git+https://github.com/dask/dask"

However, does it support installing extra components when installing from a local Python package? For example, if I have the dask Python package downloaded to local, how can I install it with specific extra components?

2

There are 2 best solutions below

0
Benjamin Du On

I've just figured it out.

pip3 install "dsutil[cv] @ file:///home/dclong/dsutil-0.54.1-py3-none-any.whl"
0
jidicula On

Yes, you can install extras from a local package. If they're defined in the package's setup.py file in the extras_require dictionary, then you can install them with pip install ."[extra1, extra2]". For example, if you have the following in your setup.py:

extras_require={
        'docs': ["sphinx>=1.6", "sphinx_rtd_theme>=0.2.4", "sphinx-click"],
        'dev': ["pre-commit>=2.10.0"]
    },

you can install the docs and dev extras with pip install ".[docs, dev]" when you're in the directory containing setup.py (you'd use the path to the directory containing setup.py in the place of . otherwise).