73

Im trying to install python pip in my alpine using Docker compose file but get the following error.

ERROR: unsatisfiable constraints:
  py-pip (missing):
    required by: world[py-pip]
ERROR: Service 'web' failed to build: The command '/bin/sh -c apk add py-pip' returned a non-zero code: 1
user1050619
  • 19,822
  • 85
  • 237
  • 413

10 Answers10

109

Do update first:

apk add --update py-pip

Or:

apk update
apk add py-pip
Robert
  • 33,429
  • 8
  • 90
  • 94
23

For python3 on alpine edge:

apk add py3-setuptools

valiano
  • 16,433
  • 7
  • 64
  • 79
user2601130
  • 231
  • 2
  • 3
22

You have to use appropriate pip version depending on Alpine branch:

  • Alpine v3.12 or newer, use apk add --update py3-pip
  • Alpine v3.5 - v3.11, use apk add --update py2-pip
  • Alpine v3.3 - v3.4, use apk add --update py-pip
wypieprz
  • 7,981
  • 4
  • 43
  • 46
8

For me --no-cache option worked.

apk add --no-cache py-pip

Yogesh Jilhawar
  • 5,605
  • 8
  • 44
  • 59
8

I've found the following:

$ apk add --update py3-pip
2

Following command in the console should work with any linux distro:

python -m ensurepip --upgrade

Tested succesfully with Alpine v3.17 the VM edition. More details here.

stancikcom
  • 74
  • 3
1

AlpineWSL 3.14.0 | Last commands is a solution, info from ircs://irc.oftc.net/alpine-linux

apk update
apk upgrade
apk add python2
python -m ensurepip --upgrade

Example

pip install -r requirements.txt
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
...
Successfully installed certifi-2021.10.8 chardet-4.0.0 idna-2.10 requests-2.26.0 urllib3-1.26.7
WARNING: You are using pip version 19.2.3, however version 20.3.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
SiB
  • 49
  • 3
  • This worked for me for Python 3 (specifically using `python3` instead of `python2`) on Alpine 3.17.0-rc4 – Peter Jan 02 '23 at 03:18
-1

You need to modify your repository:

Modify the file /etc/apk/repositories

Add the repository community

g.e.:

/media/mmcblk0p1/apks
http://alpine.42.fr/v3.14/main
http://alpine.42.fr/v3.14/community

For me, the server used is http://alpine.42.fr, but you can use another server

Don't forget to commit your change if you want to have this configuration permanently

lbu commit -d
lbontron
  • 19
  • 4
-1

This worked for me:

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py && python get-pip.py
DimiDak
  • 4,820
  • 2
  • 26
  • 32
-2

The command '/bin/sh -c pip install django-mass-edit && pip install django-admin-list-filter-dropdown && pip install SQLAlchemy && pip