-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installing psycopg2-binary with Python:3.6.4-alpine doesn't work #684
Comments
Alpine Linux use musl libc and manylinux wheels don't support it: see e.g. pypa/manylinux#37. Not a psycopg problem but a lack of a standard for it, such as PEP 513 defininig |
I found this solution which worked quite fine.
Edit The above compiles the package from source, so I would rather
not to get confused. |
But I think you are |
@nourchawich your "solution" is about compiling psycopg from source, which is totally supported. Binary packages are not (for the reason described above). |
Thank for the clarification @barrachri and @dvarrazzo I just noticed what was actually happening. All I wanted was to have psycopg2 (regardless whether binary or not) installed on an alpine based image, hence considering it a solution. |
@nourchawich after it's been built, I suppose we can get rid of those dev packages ? |
Yes, but make sure the RUN apk add --no-cache --virtual .build-deps \
gcc \
python3-dev \
musl-dev \
postgresql-dev \
&& pip install --no-cache-dir psycopg2 \
&& apk del --no-cache .build-deps |
Yeah I did, thanks ! |
Since this is the top google hit for this problem, use a multi-stage build to minimize the final image size.
|
This is still a bit unclear to me. The point of installing I'm getting the same message as the original poster. When trying to install |
I'm on Centos 7.4, and apparently I had to |
@hugobuddel The problem is when pip decides it can't install the psycopg2-binary wheel it falls back on building from source, which naturally requires dev packages. On alpine that's because of muslc instead of glibc. I should think this shouldn't happen on CentOS but maybe there's another conflict. |
Building on @Cerebus's answer, to get this to work with FROM python:3.6-alpine as base
FROM base as builder
RUN mkdir /install
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev
RUN pip install pipenv # to lock and create requirements.txt
WORKDIR /install
# creation of requirements.txt
COPY Pipfile ./Pipfile
RUN pipenv lock -r > requirements.txt
# everything else stays the same
RUN pip install --install-option="--prefix=/install" -r ./requirements.txt
FROM base
COPY --from=builder /install /usr/local
COPY . /app
RUN apk --no-cache add libpq
WORKDIR /app
|
While it is possible to use multi-stage builds or add libraries to compile from source, I recently started using the It installs
I found this article to be very useful in deciding which Python base image to use for production. |
psycopg/psycopg2#684 (comment) - Not supported on Alpine
psycopg/psycopg2#684 (comment) - Not supported on Alpine (cherry picked from commit f9822ea)
Haha, I have also shifted to pip-tools, much cleaner and faster!
…On Wed, Mar 4, 2020 at 2:24 PM MoVai ***@***.***> wrote:
@Pk13055 <https://github.com/Pk13055> I would avoid using pipenv as it
seems to be dead <pypa/pipenv#4058>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#684?email_source=notifications&email_token=ADG23DA7NYD4ZAYDIEC22NLRFYJLZA5CNFSM4ESZDXMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENW5AXA#issuecomment-594399324>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADG23DCHUYRUGZNEUWVTXDDRFYJLZANCNFSM4ESZDXMA>
.
--
*Regards*
Pratik Kamble
|
psycopg/psycopg2#684 (comment) - Not supported on Alpine (cherry picked from commit f9822ea) (cherry picked from commit 947c05f)
@MosheVai pipenv appears to have pulled a Lazarus as of a few hours ago. |
Looks like musllinux support has been added to manylinux: pypa/manylinux#1135 Perhaps this issue could have a revisit? |
seems to work too. |
not able to install psycopg2 on my docker environment requirement.txt dockerfile ENV PYTHONUNBUFFERED 1 COPY ./requirements.txt /tmp/requirements.txt ARG DEV=false ENV PATH="/py/bin:$PATH" USER django-user |
When you try to install the binary version of the lib you get the source version error.
The text was updated successfully, but these errors were encountered: