I am trying to install aerospike for python 3.8.14 on alpine 1.16.2.
Following offical documanetion I've already built aerospike-client-c 4.6.18 (release), successfully installed aerospike using pip.
Problem is that I got following error:
uv_async_send: symbol not found
ImportError: Error relocating /usr/local/lib/python3.8/site-packages/aerospike.cpython-38-x86_64-linux-gnu.so: uv_async_send: symbol not found
I've tried use ./install_libuv in aearospike-c-client but it didn't help.
I am not familair with all these building stuff, so maybe I am missing something.
Any ideas I can work out?
Command that failed:
python3 -c 'import aerospike'
My current Dockerfile:
ARG PYTHON_VERSION=3.8
FROM python:${PYTHON_VERSION}-alpine as aerospike-c-builder
ENV AS_C_VERSION=4.6.18
WORKDIR /src
RUN apk update
RUN apk add --no-cache \
build-base \
bash linux-headers \
libuv libuv-dev \
openssl openssl-dev \
lua5.1 lua5.1-dev zlib-dev
RUN wget https://artifacts.aerospike.com/aerospike-client-c/${AS_C_VERSION}/aerospike-client-c-src-${AS_C_VERSION}.zip \
&& unzip aerospike-client-c-src-${AS_C_VERSION}.zip \
&& mv aerospike-client-c-src-${AS_C_VERSION} aerospike-client-c \
&& cd aerospike-client-c \
&& make EVENT_LIB=libuv
# Stage 2: Build Aerospike Python client
FROM python:${PYTHON_VERSION}-alpine as aerospike-python-builder
ENV AS_PYTHON_VERSION=4.0.0
WORKDIR /src
COPY --from=aerospike-c-builder /src/aerospike-client-c/target/Linux-x86_64/ aerospike-client-c/
ENV PREFIX=/src/aerospike-client-c/
RUN apk update
RUN apk add --no-cache \
build-base \
bash \
linux-headers \
zlib-dev \
openssl-dev \
git
ENV DOWNLOAD_C_CLIENT 0
RUN pip --no-cache-dir install aerospike==${AS_PYTHON_VERSION}
I'm trying to build a docker image, return error:
DNS lookup error
Dockerfile:
FROM python:3.7-alpine
LABEL maintainer="r.ofc#hotmail.com"
ENV PROJECT_ROOT /app
WORKDIR $PROJECT_ROOT
RUN apk update \
&& apk add mariadb-dev \
gcc\
python3-dev \
pango-dev \
cairo-dev \
libtool \
linux-headers \
musl-dev \
libffi-dev \
openssl-dev \
jpeg-dev \
zlib-dev
RUN pip install --upgrade pip
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
CMD python manage.py runserver 0.0.0.0:8000
i'm runing kubernetes locale useing minikube
I got this error when i run command
sudo docker-compose up
Docker File:
FROM alpine
ARG AWS_RDS_USER
ARG AWS_RDS_PASSWORD
ARG AWS_RDS_HOST
ARG AWS_RDS_DATABASE
ARG LOCALE_SERVICE_URL
ARG CRYPTO_KEY
ENV APP_DIR=/app
ENV APP_ENV=production
ENV DATABASE_CONNECTION_STRING=mysql://${AWS_RDS_USER}:${AWS_RDS_PASSWORD}#${AWS_RDS_HOST}/${AWS_RDS_DATABASE}
ENV LOCALE_SERVICE_URL=$LOCALE_SERVICE_URL
ENV CRYPTO_KEY=$CRYPTO_KEY
COPY build/requirements.txt build/app.ini ${APP_DIR}/
COPY build/nginx.conf /etc/nginx/nginx.conf
COPY api ${APP_DIR}/api
RUN apk add --no-cache curl python pkgconfig python-dev openssl-dev libffi-dev musl-dev make gcc
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python
RUN apk update && \
apk add --virtual .build-deps autoconf gcc make g++ python-dev && \
apk add nginx uwsgi uwsgi-python py2-pip py-mysqldb && \
chown -R nginx:nginx ${APP_DIR} && \
chmod 777 /run/ -R && \
chmod 777 /root/ -R && \
pip2 install --upgrade pip && \
pip2 install -r ${APP_DIR}/requirements.txt && \
apk del .build-deps && \
rm -fR tmp/* && \
pw_migrate migrate --database=$DATABASE_CONNECTION_STRING --directory=$APP_DIR/api/migrations -v
EXPOSE 80
CMD nginx && uwsgi --ini ${APP_DIR}/app.ini
For solution, I tried to install below packages
1) gcc package.
2) libffi packages.
3) pip openssl packages.
But still error is not resolved. Any help should be appreciated
Try the solution suggested here
This is because you need a working compiler, the easiest way around
this is too install the build-base package like so:
apk add --no-cache --virtual .pynacl_deps build-base python3-dev
libffi-dev This will install various tools that are required to
compile pynacl and pip install pynacl will now succeed.
Note it is optional to use the --virtual flag but it makes it easy to
trim the image because you can run apk del .pynacl_deps later in your
dockerfile as they are not needed any more and would reduce the
overall size of the image.
I am trying to create slim image with gunicorn Pillow numpy scipy PyBrain dependencies. However whatever I do, my image size becomes above 500 MB. Is there a any trick to decrease the size of the docker image?
FROM python:2.7-alpine
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk --update add --no-cache \
lapack-dev \
gcc \
freetype-dev
RUN apk add --no-cache --virtual .build-deps \
gfortran \
musl-dev \
g++ \
jpeg-dev \
zlib-dev
RUN apk add --update tini
COPY requirements.txt /app/
COPY app/ /app/
WORKDIR /app
RUN pip install numpy==1.13.3
RUN pip install -r requirements.txt
RUN apk del .build-deps
EXPOSE 8080
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["gunicorn", "-w 3", "-b :8080", "app:app"]
Build dependencies need to be removed in the same RUN command to avoid them being stored into their own layer. For example:
COPY requirements.txt /app/
RUN apk add --no-cache --virtual .build-deps \
gfortran \
musl-dev \
g++ \
jpeg-dev \
zlib-dev \
&& pip install -r requirements.txt \
&& apk del .build-deps
Note that this will result in additional build time every time requirements are updated because apk commands will be executed as well. If that is not acceptable for your application, then just remove the RUN apk del .build-deps step since that doesn't reduce image size, but it increases it given that the addition/removal of packages happen in different image layers.
To use PostgreSql in python I need to
pip install psycopg2
However, it has dependency on libpq-dev and python-dev. I wonder how can I install the dependencies in alpine? Thanks.
Here is a Dockerfile:
FROM python:2.7-alpine
RUN apk add python-dev libpq-dev
RUN pip install psycopg2
and the output is:
Step 3 : RUN apk add python-dev libpq-dev ---> Running in
3223b1bf7cde WARNING: Ignoring APKINDEX.167438ca.tar.gz: No such file
or directory WARNING: Ignoring APKINDEX.a2e6dac0.tar.gz: No such file
or directory ERROR: unsatisfiable constraints: libpq-dev (missing):
required by: world[libpq-dev] python-dev (missing):
required by: world[python-dev] ERROR: Service 'service' failed to build: The command '/bin/sh -c apk add python-dev libpq-dev' returned
a non-zero code: 2
If you only need to install psycopg2 for python 2.7 on Docker image based on python:2.7-alpine then following code for Dockerfile will be nice for you:
FROM python:2.7-alpine
RUN apk update && \
apk add --virtual build-deps gcc python-dev musl-dev && \
apk add postgresql-dev
RUN pip install psycopg2
An explanation before compile/install psycopg2
libpq is the client library for PostgreSQL
postgresql-dev are the package with the source headers to link libpq in a library/binary in a compilation, in this case when pip compiles psycopg .
I use the following configuration in alpine 3.7, I add some comments to explain it.
# Installing client libraries and any other package you need
RUN apk update && apk add libpq
# Installing build dependencies
# For python3 you need to add python3-dev *please upvote the comment
# of #its30 below if you use this*
RUN apk add --virtual .build-deps gcc python-dev musl-dev postgresql-dev
# Installing and build python module
RUN pip install psycopg2
# Delete build dependencies
RUN apk del .build-deps
Had problems with running Python 3.7 and PostgreSQL under Alpine Linux in Docker.
This article helped https://www.rockyourcode.com/install-psycopg2-binary-with-docker/
The main thing is to reference psypcopg2-binary in your requirements file and install the following packages (in Dockerfile):
RUN apk update && \
apk add --no-cache --virtual build-deps gcc python3-dev musl-dev && \
apk add postgresql-dev
I couldn't get it to install from python:2.7.13-alpine. Ended up with this:
FROM gliderlabs/alpine:3.3
RUN apk add --no-cache --update \
python \
python-dev \
py-pip \
build-base
RUN apk add --virtual build-deps gcc python-dev musl-dev && \
apk add --no-cache --update postgresql-dev && \
pip install psycopg2==2.7.1
Seems like the package you need is libpq not libpq-dev:
https://pkgs.alpinelinux.org/package/edge/main/x86/py2-psycopg2
Have a look at the dependencies at the right
add it in dockerfile
RUN apk update && apk add --no-cache --virtual .build-deps\
postgresql-dev gcc libpq python3-dev musl-dev linux-headers\
&& pip install --no-cache-dir -r requirements.txt\
&& apk del .build-deps\
&& rm -rf /var/cache/apk/*
What helped me was:
RUN apk add --no-cache python3 \
&& python3 -m ensurepip \
&& pip3 install --upgrade pip setuptools \
&& apk add build-base \
&& apk add gcc musl-dev libffi-dev openssl-dev python3-dev \
&& apk add postgresql-dev \
&& rm -r /usr/lib/python*/ensurepip && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
rm -r /root/.cache
RUN pip install --trusted-host pypi.python.org psycopg2
Especially apk add gcc musl-dev libffi-dev openssl-dev python3-dev as indicated in Docker: Installing python cryptography on alpine linux distribution
This may have to something with blockage of some countries by docker so you may sure you are using vpn