I am trying to build a dockerfile but the problem is when it trying to build specifically cryptography is not building.
MY Dockerfile
FROM python:3.7-alpine ENV PYTHONUNBUFFERED 1 RUN apk update \ # psycopg2 dependencies && apk add --virtual build-deps gcc python3-dev musl-dev\ && apk add postgresql-dev \ && apk add build-base \ # Pillow dependencies && apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \ # CFFI dependencies && apk add libffi-dev py-cffi \ # Translations dependencies && apk add gettext \ # https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell && apk add postgresql-client \ # cairo && apk add cairo cairo-dev pango-dev gdk-pixbuf-dev poppler-utils # fonts for weasyprint RUN mkdir ~/.fonts COPY ./fonts/* /root/.fonts/ # secret key (should be in docker-secrets, or we need to run minikube locally RUN mkdir /etc/secrets COPY secret.readme proxy_rsa_key* /etc/secrets/ # Requirements are installed here to ensure they will be cached. COPY ./requirements /requirements RUN pip install -r /requirements/local.txt COPY ./compose/local/django/entrypoint /entrypoint RUN sed -i 's/\r//' /entrypoint RUN chmod +x /entrypoint COPY ./compose/local/django/start /start RUN sed -i 's/\r//' /start RUN chmod +x /start COPY ./compose/local/django/celery/worker/start /start-celeryworker RUN sed -i 's/\r//' /start-celeryworker RUN chmod +x /start-celeryworker COPY ./compose/local/django/celery/beat/start /start-celerybeat RUN sed -i 's/\r//' /start-celerybeat RUN chmod +x /start-celerybeat COPY ./compose/local/django/celery/flower/start /start-flower RUN sed -i 's/\r//' /start-flower RUN chmod +x /start-flower WORKDIR /app ENTRYPOINT ["/entrypoint"]
when I try to build my dockerfile it shows:
Building wheel for cryptography (PEP 517): finished with status 'error' ERROR: Command errored out with exit status 1: error: Can not find Rust compiler ---------------------------------------- ERROR: Failed building wheel for cryptography
I tried to solve but i couldn't. I am newbie in docker.Please help how to get rid of this problem.
cryptography failed to install! If you are having issues installing cryptography the first troubleshooting step is to upgrade pip and then try to install again. For most users this will take the form of pip install -U pip , but on Windows you should do python -m pip install -U pip .
How To Solve ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly Error ? To Solve ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly Error Just open your requirement. txt file. And just Set cryptography to version 2.8 or 2.9.
cryptography < 3.5:
You can skip the rust installation and other related dependencies by adding the line below before apk add commands:
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
cryptography >= 3.5: Thanks @riptusk331
After this version rust will be required. Either install a specific version <3.5 or follow cryptography installation instructions. It is stated in the attached link that they are very aggressively explained in the docs.
Since the error is...
error: Can not find Rust compiler
...the solution is to install the rust compiler. You'll also need cargo
, the Rust package manager, and it looks like your Dockerfile
is missing openssl-dev
.
The following builds successfully for me:
FROM python:3.7-alpine ENV PYTHONUNBUFFERED 1 RUN apk add --update \ build-base \ cairo \ cairo-dev \ cargo \ freetype-dev \ gcc \ gdk-pixbuf-dev \ gettext \ jpeg-dev \ lcms2-dev \ libffi-dev \ musl-dev \ openjpeg-dev \ openssl-dev \ pango-dev \ poppler-utils \ postgresql-client \ postgresql-dev \ py-cffi \ python3-dev \ rust \ tcl-dev \ tiff-dev \ tk-dev \ zlib-dev RUN pip install cryptography
Note that the above apk add ...
command line is largely the same as what you've got; I've just simplified the multiple apk add ...
statements into a single apk add
execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With