# Using pip to install python wheels

**URL:** <https://forums.balena.io/t/using-pip-to-install-python-wheels/6110>\
**Category:** Product support\
**Tags:** raspberrypi3\
**Created:** [April 17, 2019, 5:26pm UTC](https://forums.balena.io/t/using-pip-to-install-python-wheels/6110 "2019-04-17T17:26:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpgmiskin](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hpgmiskin/32/464_2.png) [@hpgmiskin](https://forums.balena.io/u/hpgmiskin)\
**Post date:** [April 17, 2019, 5:26pm UTC](https://forums.balena.io/t/using-pip-to-install-python-wheels/6110/1 "2019-04-17T17:26:14Z")

</div>

I am installing packages using pip while building for a Raspberry Pi 3. I have found a source of wheels that should allow the installation to run much faster however the installation does not pickup up wheels with architecture `linux_armv7l`

```
pip install --requirement requirements.txt --extra-index-url https://www.piwheels.hostedpi.com/simple

```

Has anyone had any experience with the above? From looking at [piwheels blog](https://www.raspberrypi.org/blog/piwheels/) it may be that I am just getting the architecture wrong and it needs to be `armv7l` not `linux_armv7l`. It would be great to get this working to avoid building massive packages.

---

<div class="post-metadata">

**Author:** ![pcgeek86](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcgeek86/32/1455_2.png) [@pcgeek86](https://forums.balena.io/u/pcgeek86)\
**Post date:** [April 17, 2019, 6:14pm UTC](https://forums.balena.io/t/using-pip-to-install-python-wheels/6110/3 "2019-04-17T18:14:32Z")

</div>

Hello @hpgmiskin,

Here’s a simple `Dockerfile.template` that you can use, as an example. You want to use `--index-url` instead of `--extra-index-url`, because you want to override the PyPi default repository. As you can see in the logs I pasted below, from my test build, there is only a single index being searched for Python wheels, instead of two. Also, you can observe that the URIs where wheels are being pulled from, are using the [piwheels.org](http://piwheels.org) host, instead of [files.pythonhosted.org](http://files.pythonhosted.org).

### Dockerfile.template

```auto
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3

RUN apt-get update \
  && apt-get upgrade --yes \
  && pip3 install flake8 --index-url=https://piwheels.org/simple

```

### Logs

```auto
[main] Looking in indexes: https://piwheels.org/simple
[main] Collecting flake8
[main] Downloading https://piwheels.org/simple/flake8/flake8-3.7.7-py2.py3-none-any.whl (68kB)
[main] Collecting pyflakes<2.2.0,>=2.1.0 (from flake8)
[main] Downloading https://piwheels.org/simple/pyflakes/pyflakes-2.1.0-py2.py3-none-any.whl (62kB)
[main] Collecting entrypoints<0.4.0,>=0.3.0 (from flake8)
[main] Downloading https://piwheels.org/simple/entrypoints/entrypoints-0.3-py2.py3-none-any.whl
[main] Collecting mccabe<0.7.0,>=0.6.0 (from flake8)
[main] Downloading https://piwheels.org/simple/mccabe/mccabe-0.6.1-py2.py3-none-any.whl
[main] Collecting pycodestyle<2.6.0,>=2.5.0 (from flake8)
[main] Downloading https://piwheels.org/simple/pycodestyle/pycodestyle-2.5.0-py2.py3-none-any.whl (51kB)
[main] Installing collected packages: pyflakes, entrypoints, mccabe, pycodestyle, flake8
[main] Successfully installed entrypoints-0.3 flake8-3.7.7 mccabe-0.6.1 pycodestyle-2.5.0 pyflakes-2.1.0

```

I hope this helps.

Cheers,  
Trevor Sullivan

---

<div class="post-metadata">

**Author:** ![hpgmiskin](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hpgmiskin/32/464_2.png) [@hpgmiskin](https://forums.balena.io/u/hpgmiskin)\
**Post date:** [April 18, 2019, 12:47pm UTC](https://forums.balena.io/t/using-pip-to-install-python-wheels/6110/4 "2019-04-18T12:47:46Z")

</div>

Hello @pcgeek86,

Thanks for such a rapid response.

I experimented with using `--index-url` and `--extra-index-url`. I think its better to use `--extra-index-url` as pip will search both indexes for `.whl` files and always prefer them over `.tar.gz`. I had installations fail when I did not give pip two options for where to find packages.

In writhing this response to you I have identified the issue with my installation. I was using Python 3.7 however the `.whl` I was attempting to use was only compiled for python version 3.6. I would recommend trying to find a version of package that can be installed from a `.whl`. In order to find which versions are available its important to understand the structure of the `.whl` files.  
Here is a section from [PEP 427](https://www.python.org/dev/peps/pep-0427/#file-name-convention) in the code snippet below.

```
{distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl

```

For example if trying to install numpy on Raspberry Pi 3 the platform is `armv7l`. Once you know your platform it’s just a case of searching [https://pypi.org/simple/numpy/](https://pypi.org/simple/numpy/) and [https://www.piwheels.hostedpi.com/simple/numpy/](https://www.piwheels.hostedpi.com/simple/numpy/) to find a matching `.whl` for the library.

There are no numpy `.whl` files compiled for `armv7l` on the default index however looking at the piwheels index there are a number of versions available. At time of writing you could choose `numpy==1.10.4` for python3.6 or use `numpy==1.16.0` for python 3.5 (from the release candidate for `numpy==1.16.1` it looks like there will be a `.whl` available for python3.6).

Perhaps this is a counterintuitive approach and I would welcome comments if that is the case. However I found that using the wheel binary package format improved installation times dramatically and avoided having to install the toolbelt required to build packages from source.

I hope this helps others in a similar predicament,  
Henry
