gyuunyuu
gyuunyuu

Reputation: 684

Why do I get so many wheel files when I download a Python package using pip

I executed this:

$ pip download virtualenv
Collecting virtualenv
  Using cached virtualenv-20.0.31-py2.py3-none-any.whl (4.9 MB)
  Saved d:\test\gits\virtualenv-20.0.31-py2.py3-none-any.whl
Collecting appdirs<2,>=1.4.3
  Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
  Saved d:\test\gits\appdirs-1.4.4-py2.py3-none-any.whl
Collecting six<2,>=1.9.0
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
  Saved d:\test\gits\six-1.15.0-py2.py3-none-any.whl
Collecting distlib<1,>=0.3.1
  Using cached distlib-0.3.1-py2.py3-none-any.whl (335 kB)
  Saved d:\test\gits\distlib-0.3.1-py2.py3-none-any.whl
Collecting filelock<4,>=3.0.0
  Using cached filelock-3.0.12-py3-none-any.whl (7.6 kB)
  Saved d:\test\gits\filelock-3.0.12-py3-none-any.whl
Successfully downloaded virtualenv appdirs six distlib filelock

Although I attempted to download one package, I got these wheel files:

appdirs-1.4.4-py2.py3-none-any.whl  
six-1.15.0-py2.py3-none-any.whl
distlib-0.3.1-py2.py3-none-any.whl  
virtualenv-20.0.31-py2.py3-none-any.whl
filelock-3.0.12-py3-none-any.whl

Now my questions are:

  1. Why are there so many wheel files,and not just one file called virtualenv-20.0.31-py2.py3-none-any.whl?
  2. Now once I have this downloaded and stored somewhere on my computer or network location, how do I do the install?
  3. What happens if I just have the virtualenv-20.0.31-py2.py3-none-any.whl and no other wheel file when I attemp the install?

Upvotes: 1

Views: 1305

Answers (2)

phd
phd

Reputation: 94445

  1. Those additional wheels are dependencies, including recursive (transitive) dependencies, i.e. dependencies of dependencies.

pip install --find-links /path/to/download/dir/ virtualenv-20.0.31-py2.py3-none-any.whl
  1. pip tries to download dependencies from the configured index server, default is PyPI. Failed to download any dependency pip fails to install anything. It exits with an error message and an error code.

Upvotes: 1

wim
wim

Reputation: 362617

1 . Using pip download also downloads the dependencies, and those extra files that you saw are precisely the deps of the virtualenv distribution:

$ johnnydep virtualenv
name                    summary
----------------------  -------------------------------------------------------------------------------------------------
virtualenv              Virtual Python Environment builder
├── appdirs<2,>=1.4.3   A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".
├── distlib<1,>=0.3.1   Distribution utilities
├── filelock<4,>=3.0.0  A platform independent file lock.
└── six<2,>=1.9.0       Python 2 and 3 compatibility utilities

If you only want the package itself without dependencies, use:

pip download --no-deps virtualenv

2 . You can install a wheel file directly with pip

pip install ./virtualenv-20.0.31-py2.py3-none-any.whl

3 . If you install with --no-deps the app won't work properly, probably it will crash with some ImportError due to missing dependencies.

$ pip install -q --no-deps virtualenv
$ virtualenv .venv
Traceback (most recent call last):
    ...
ModuleNotFoundError: No module named 'appdirs'

Otherwise it will just collect and install the dependencies from PyPI, or whatever index your pip is configured at - see pip config list.

Upvotes: 1

Related Questions