Alpine package py3-scipy is missing - docker

I'm in an alpine linux docker container, and I'm trying to install py3-scipy. Here is info on that package: https://pkgs.alpinelinux.org/package/edge/community/x86/py3-scipy. I want to do this because pip install scipy takes way too long.
Here is what I get:
/ # apk add py3-scipy
ERROR: unsatisfiable constraints:
py3-scipy (missing):
required by: world[py3-scipy]
My Dockerfile:
FROM alpine:3.9
RUN apk add --update python3-dev g++ gcc libxslt-dev cython lapack-dev gfortran build-base py3-scipy
What is causing this error?

I think this issue sometimes happen when alpine moves a package from edge/testing to edge/community so old versions of alpine will keep referring to the old url. So you need to try to use the latest alpine version alpine:latest instead of a specific version.

I was missing the echo step, with that I was able to install it:
echo "#testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
apk add --update --no-cache py3-scipy

Related

Docker Alpine Linux python (missing)

I have a pipeline which deploys my container from GitLab. Last deployment was 5 days ago and went without any problems. Today I deploy it and get the following error:
$ apk add --no-cache curl python py-pip
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
python (missing):
required by: world[python]
My job definition is:
my-deploy:
type: my-deploy
image: docker:stable
script:
- apk update
- apk add --no-cache curl python py-pip <-- Here the erorr happens
...
From this issue on the Docker's repo:
This was "broken" while updating our base from alpine:3.11 to alpine:3.12.
In order to fix it you need to specify the version of Python directly, e.g.:
apk add python2
// or
apk add python3
Try this command:
apk add --update --no-cache curl py-pip
It will install python3 automatically with pip.
My understanding is that Python 2 has been decommissioned from the latest Alpine packages.
For future readers:
I got a similar error with node:14-alpine
ERROR: unable to select packages:
python2 (no such package):
required by: world[python2]
But I couldn't use the other answers listed in this question because I needed exactly python2 and running apk add python2 was giving me the error above.
After a while I realized that in the latest alpine version, there's only python3 (there's no python2).
So the solution was to use an older version of alpine that have python2 (alpine v3.15).
So the fix was changing node:14-alpine to node:14-alpine3.15
I know this isn't the exact same error, but while trying to find an answer for my error, I always ended up here, so I'm leaving this for future readers that might have the same problem.
I've fix following this
https://gitlab.alpinelinux.org/alpine/aports/-/issues/11605
Updating your code to install python3:
before_script:
- apk add --update --no-cache curl jq py3-configobj py3-pip py3-setuptools python3 python3-dev
What solved it for me is this solution posted on GitHub.
RUN echo -e "http://nl.alpinelinux.org/alpine/v3.5/main\nhttp://nl.alpinelinux.org/alpine/v3.5/community" > /etc/apk/repositories

Docker alpine apk cannot find git-lfs package

I'm trying to install git-lfs in a Docker alpine image, but I'm getting an error indicating:
ERROR: unsatisfiable constraints:
git-lfs (missing):
required by: world[git-lfs]
It seems that there has been many issues related to apk not finding packages (see here and there), and in many cases these have been solved by using the --no-cache option with apk add. But I am not being that lucky and cannot understand the origin of this error, specially considering that git-lfs is up to date in alpine repo.
The following small Dockerfile should reproduce the error:
FROM alpine:3.4
RUN apk update && apk add --no-cache \
build-base \
git \
git-lfs
The problem is that git-lfs is available only from alpine:3.7.
To fix the issue you should either rebuild it on your own or use an alpine version >=3.7.
Btw, you don't need to execute apk update.

What package should I install instead of libpcre++-dev to use C code in Alpine Golang?

I have a Golang program inside a docker container (I use Ubuntu 18). Also I use github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre for regex in my Golang app. Before using this library I should install libpcre++-dev this way:
sudo apt-get install libpcre++-dev
But I use golang:alpine in my Dockerfile and this is no libpcre++-dev library in alpine packages.
What package should I install instead of libpcre++-dev?
p.s. I have tried to install libc6-compat, pcre pcre-dev, libpcrecpp but I see this error:
github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre
/go/pkg/mod/github.com/glenn-brown/golang-pkg-pcre#v0.0.0-20120522223659-48bb82a8b8ce/src/pkg/pcre/pcre.go:52:10:
fatal error: pcre.h: No such file or directory #include
^~~~~~~~ compilation terminated
My Dockerfile:
FROM golang:alpine
RUN apk update
RUN apk upgrade
RUN apk add --update --no-cache build-base gcc g++ pcre pcre-dev libc6-compat
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache curl git ca-certificates tzdata \
&& update-ca-certificates 2> /dev/null || true
I build my app this way:
- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/backend ./cmd/backend/main.go
EDIT
I have change my Dockerfile (add line below)
RUN apk add --update --no-cache build-base gcc g++ pcre pcre-dev libc6-compat
And now I have a new error:
Error loading shared library libpcre.so.1: No such file or directory
(needed by /bin/backend)
You can try one of these, as both package
RUN apk add --virtual build-dependencies
RUn apk add --no-cache build-base gcc
build-essential is a metapackage (a package that installs many other
packages, like g++ and gcc: the GNU C & C++ compilers).
Or you can install the alpine sdk.
You can start with alpine-sdk, which is a "metapackage that pulls in
the most essential packages used to build new packages."
http://wiki.alpinelinux.org/wiki/Developer_Documentation has more
info.
RUN apk add --update alpine-sdk
docker-alpine-issues-24
Or you can use golang:latest which will work fine.
FROM golang:latest
RUN apt-get update
RUN apt-get install libpcre++-dev -y
You can use one of the Debian-based golang images instead. By the time you're installing GNU libc and a full C toolchain on top of this anyways, there's not really going to be much space savings over the Alpine base image. You can (and should) use a multi-stage build where the final image just contains your compiled binary, and that can use an Alpine base.
The result would look something like:
# Build-time image; just has the parts needed to run `go build`
FROM golang:1.12-buster AS build
# Install additional build-time tools
RUN apt-get update \
&& apt-get install --assume-yes \
build-essential ca-certificates git-core tzdata \
libpcre++-dev
# Build your application
WORKDIR /app
COPY . .
ENV GO111MODULE=on
RUN go build -o myapp ./cmd/myapp
# Runtime image; has only what we need to run the application
FROM alpine:3.10
# Note that you'll need the shared library for libpcre++
RUN apk add ca-certificates tzdata libpcrepp
COPY --from=build /app/myapp /usr/bin/myapp
CMD ["myapp"]

What library contains cdefs.h on Alpine?

I am trying to compile some code on a Docker image running Alpine. However, gcc keeps terminating due to fatal error: sys/cdefs.h: No such file or directory. People on Google were saying to do
apt install libc6-dev-i386 gcc-multilib
Which I translated to apk add libc6-dev-i386 gcc-multilib. However, then I just get the error. ERROR: unsatisfiable constraints: for both of the libraries.
My Dockerfile is as follows:
FROM alpine
ADD . .
RUN apk update && apk add gcc make openssl libressl-dev musl-dev && make
ENTRYPOINT ./restrictions-crack "$hash" "$salt"
I ended up finding it, the library is bsd-compat-headers
You might use build-base - this is a meta-package that will install the GCC, libc-dev and binutils packages (amongst others).
Dockerfile:
FROM alpine
ADD . .
RUN apk update && apk add build-base && make
ENTRYPOINT ./restrictions-crack "$hash" "$salt"

alpine package py-pip missing

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
Do update first:
apk add --update py-pip
Or:
apk update
apk add py-pip
For python3 on alpine edge:
apk add py3-setuptools
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
For me --no-cache option worked.
apk add --no-cache py-pip
I've found the following:
$ apk add --update py3-pip
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.
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.
This worked for me:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py && python get-pip.py
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
The command '/bin/sh -c pip install django-mass-edit && pip install django-admin-list-filter-dropdown && pip install SQLAlchemy && pip

Resources