I am trying to build a docker image for a flask application, which requires pymssql to connect to the sql server. Have specified pymssql===2.2.5 in the requirements.txt file and trying to build the image.
I have tried docker build -t <image-name> .
Collecting pymssql==2.2.5
#9 23.25 Downloading pymssql-2.2.5.tar.gz (170 kB)
#9 23.27 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 170.1/170.1 KB 9.9 MB/s eta 0:00:00
#9 23.38 Installing build dependencies: started
#9 27.65 Installing build dependencies: finished with status 'done'
#9 27.65 Getting requirements to build wheel: started
#9 27.90 Getting requirements to build wheel: finished with status 'error'
#9 27.90 error: subprocess-exited-with-error
#9 27.90
#9 27.90 × Getting requirements to build wheel did not run successfully.
#9 27.90 │ exit code: 1
#9 27.90 ╰─> [6 lines of output]
#9 27.90 setup.py: platform.system() => Linux
#9 27.90 setup.py: platform.architecture() => ('64bit', '')
#9 27.90 setup.py: platform.libc_ver() => ('glibc', '2.31')
#9 27.90 setup.py: include_dirs => []
#9 27.90 setup.py: library_dirs => []
#9 27.90 setup.py: could not locate 'clock_gettime' function required by FreeTDS.
#9 27.90 [end of output]
#9 27.90
#9 27.90 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 27.90 error: subprocess-exited-with-error
Related
I'm new to Docker and I'm trying to dockerize a Django app but when I run docker build -t sometag . I receive the following error:
#9 23.05 Preparing metadata (setup.py): started
#9 23.32 Preparing metadata (setup.py): finished with status 'error'
#9 23.33 error: subprocess-exited-with-error
#9 23.33
#9 23.33 × python setup.py egg_info did not run successfully.
#9 23.33 │ exit code: 1
#9 23.33 ╰─> [10 lines of output]
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: Attempting build of _rl_accel
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: extensions from 'src/rl_addons/rl_accel'
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ===================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: Attempting build of _renderPM
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: extensions from 'src/rl_addons/renderPM'
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: ===================================================
#9 23.33 ##### setup-python-3.10.8-linux-x86_64: will use package libart 2.3.21
#9 23.33 !!!!! cannot find ft2build.h
#9 23.33 [end of output]
#9 23.33
#9 23.33 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 23.33 error: metadata-generation-failed
#9 23.33
#9 23.33 × Encountered error while generating package metadata.
#9 23.33 ╰─> See above for output.
#9 23.33
#9 23.33 note: This is an issue with the package mentioned above, not pip.
#9 23.33 hint: See above for details.
------
executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
I'm not sure if it is related to ft2build.h.I'm I missing something on my dockerfile?
This is my requirements.txt:
arabic-reshaper==2.1.3
asn1crypto==1.5.1
attrs==20.3.0
azure-core==1.23.1
azure-storage-blob==12.11.0
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.12
click==8.1.2
colorama==0.4.4
cryptography==36.0.2
cssselect2==0.5.0
distlib==0.3.5
Django==4.0.3
django-crispy-forms==1.14.0
django-storages==1.12.3
djangorestframework==3.14.0
filelock==3.8.0
future==0.18.2
html5lib==1.1
idna==3.3
isodate==0.6.1
jellyfish==0.9.0
lib50==3.0.4
lxml==4.8.0
markdown2==2.4.2
msrest==0.6.21
oauthlib==3.2.0
oscrypto==1.3.0
pexpect==4.8.0
Pillow==9.1.0
platformdirs==2.5.2
psycopg2-binary==2.9.3
ptyprocess==0.7.0
pycparser==2.21
pyHanko==0.12.1
pyhanko-certvalidator==0.19.5
PyPDF2==1.27.3
PyPDF3==1.0.6
python-bidi==0.4.2
pytz==2022.1
PyYAML==5.4.1
qrcode==7.3.1
reportlab==3.6.9
requests==2.27.1
requests-oauthlib==1.3.1
six==1.16.0
submit50==3.1.1
svglib==1.2.1
termcolor==1.1.0
tinycss2==1.1.1
tk==0.1.0
tqdm==4.64.0
typing_extensions==4.1.1
tzdata==2022.1
tzlocal==4.2
uritools==4.0.0
urllib3==1.26.9
virtualenv==20.16.3
webencodings==0.5.1
whitenoise==6.0.0
xhtml2pdf==0.2.7
Note: I had to remove the dockerfile as Stackoverflow wouldn't allow me to publish so much code but I'm running this RUN apk update \&& apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev \&& pip install --upgrade pip
I'm not sure if it is related to ft2build.h.I'm I missing something on my dockerfile?
To solve the problem with the error ft2build.h. in the compile process, you need the freetype library installed
I assume you are using the last version of Alpine, and I can see you can install pip packages without problems.
As a result, the missing part should be the freetype-dev package to install.
RUN apk update \
&& apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev freetype-dev\
There is a problem when I deploy a Django app in Railway, Railway is an infrastructure platform that is very similar to Heroku and it uses debian, this is the error that is in the logs.
#10 16.69 Using cached selenium-4.1.0-py3-none-any.whl (958 kB)
#10 16.75 Collecting six==1.16.0
#10 16.75 Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
#10 16.78 Collecting sniffio==1.2.0
#10 16.78 Using cached sniffio-1.2.0-py3-none-any.whl (10 kB)
#10 16.83 Collecting sortedcontainers==2.4.0
#10 16.83 Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
#10 16.89 Collecting soupsieve==2.2.1
#10 16.89 Using cached soupsieve-2.2.1-py3-none-any.whl (33 kB)
#10 16.93 Collecting sqlparse==0.4.2
#10 16.93 Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
#10 17.07 Collecting tqdm==4.62.3
#10 17.08 Using cached tqdm-4.62.3-py2.py3-none-any.whl (76 kB)
#10 17.12 Collecting trio==0.19.0
#10 17.12 Using cached trio-0.19.0-py3-none-any.whl (356 kB)
#10 17.16 Collecting trio-websocket==0.9.2
#10 17.16 Using cached trio_websocket-0.9.2-py3-none-any.whl (16 kB)
#10 17.23 Collecting twine==3.4.2
#10 17.24 Using cached twine-3.4.2-py3-none-any.whl (34 kB)
#10 17.28 Collecting tzdata==2022.1
#10 17.29 Using cached tzdata-2022.1-py2.py3-none-any.whl (339 kB)
#10 17.38 Collecting urllib3==1.26.6
#10 17.38 Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
#10 17.41 Collecting webencodings==0.5.1
#10 17.42 Using cached webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
#10 17.47 Collecting whitenoise==6.2.0
#10 17.47 Using cached whitenoise-6.2.0-py3-none-any.whl (19 kB)
#10 17.51 Collecting wsproto==1.0.0
#10 17.51 Using cached wsproto-1.0.0-py3-none-any.whl (24 kB)
#10 17.57 Collecting zipp==3.6.0
#10 17.57 Using cached zipp-3.6.0-py3-none-any.whl (5.3 kB)
#10 18.00 Collecting psycopg2
#10 18.00 Using cached psycopg2-2.9.3.tar.gz (380 kB)
#10 18.09 Preparing metadata (setup.py): started
#10 18.38 Preparing metadata (setup.py): finished with status 'error'
#10 18.39 error: subprocess-exited-with-error
#10 18.39
#10 18.39 × python setup.py egg_info did not run successfully.
#10 18.39 │ exit code: 1
#10 18.39 ╰─> [23 lines of output]
#10 18.39 running egg_info
#10 18.39 creating /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info
#10 18.39 writing /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/PKG-INFO
#10 18.39 writing dependency_links to /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/dependency_links.txt
#10 18.39 writing top-level names to /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/top_level.txt
#10 18.39 writing manifest file '/tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/SOURCES.txt'
#10 18.39
#10 18.39 Error: pg_config executable not found.
#10 18.39
#10 18.39 pg_config is required to build psycopg2 from source. Please add the directory
#10 18.39 containing pg_config to the $PATH or specify the full executable path with the
#10 18.39 option:
#10 18.39
#10 18.39 python setup.py build_ext --pg-config /path/to/pg_config build ...
#10 18.39
#10 18.39 or with the pg_config option in 'setup.cfg'.
#10 18.39
#10 18.39 If you prefer to avoid building psycopg2 from source, please install the PyPI
#10 18.39 'psycopg2-binary' package instead.
#10 18.39
#10 18.39 For further information please check the 'doc/src/install.rst' file (also at
#10 18.39 <https://www.psycopg.org/docs/install.html>;).
#10 18.39
#10 18.39 [end of output]
#10 18.39
#10 18.39 note: This error originates from a subprocess, and is likely not a problem with pip.
#10 18.39 error: metadata-generation-failed
#10 18.39
#10 18.39 × Encountered error while generating package metadata.
#10 18.39 ╰─> See above for output.
#10 18.39
#10 18.39 note: This is an issue with the package mentioned above, not pip.
#10 18.39 hint: See above for details.
#10 18.40 WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
#10 18.40 You should consider upgrading via the '/opt/venv/bin/python -m pip install --upgrade pip' command.
#10 ERROR: executor failed running [/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt]: exit code: 1
-----
> [stage-0 6/9] RUN --mount=type=cache,id=s/d3b41cd2-3817-4a81-ba7d-ff021a7d5a6f-/root/.cache/pip,target=/root/.cache/pip python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt:
-----
executor failed running [/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt]: exit code: 1
Error: Docker build failed
The error could be "Error: pg_config executable not found.", so I have looked up the error in Google, and I got that I have to change the library "psycopg2" to "psycopg2-binary", but I still get the same error.
After I tried a "template" in railway, which is like configurations for each framework, and it brings a sample app to test with, in this case, it was a Django app, in that app I saw that the dependency "psycopg2" was the version "2.8.6", and it was working, so I also replaced the version "2.9.3" to "2.8.6", but with the same result, even with replacing it with the dependency "psycopg2-binary".
This is the requirement.txt file:
asgiref==3.5.2
async-generator==1.10
attrs==21.4.0
backports.zoneinfo==0.2.1
beautifulsoup4==4.10.0
bleach==4.1.0
cached-property==1.5.2
certifi==2021.5.30
cffi==1.15.0
charset-normalizer==2.0.6
cloudinary==1.29.0
colorama==0.4.4
coverage==6.4.1
cryptography==36.0.1
dj-database-url==0.5.0
Django==4.0.4
django-environ==0.8.1
django-heroku==0.3.1
docutils==0.17.1
et-xmlfile==1.1.0
frozendict==2.0.6
genanki==0.11.0
h11==0.13.0
idna==3.2
importlib-metadata==4.8.1
keyring==23.2.1
numpy==1.22.3
openpyxl==3.0.9
outcome==1.1.0
packaging==21.0
pandas==1.4.2
pkginfo==1.7.1
psycopg2-binary==2.8.6
pycparser==2.21
Pygments==2.10.0
pyOpenSSL==22.0.0
pyparsing==3.0.0
pystache==0.6.0
python-dateutil==2.8.2
pytz==2022.1
pywin32-ctypes==0.2.0
PyYAML==5.4.1
readme-renderer==30.0
requests==2.26.0
requests-toolbelt==0.9.1
rfc3986==1.5.0
selenium==4.1.0
six==1.16.0
sniffio==1.2.0
sortedcontainers==2.4.0
soupsieve==2.2.1
sqlparse==0.4.2
tqdm==4.62.3
trio==0.19.0
trio-websocket==0.9.2
twine==3.4.2
tzdata==2022.1
urllib3==1.26.6
webencodings==0.5.1
whitenoise==6.2.0
wsproto==1.0.0
zipp==3.6.0
Is there some idea about what is happening?
Running johnnydep on your requirements.txt, shows that django-heroku depends on psycopg2:
>>> johnnydep django-heroku
2022-07-19 17:03:28 [info ] init johnnydist [johnnydep.lib] dist=django-heroku parent=None
2022-07-19 17:03:30 [info ] init johnnydist [johnnydep.lib] dist=dj-database-url>=0.5.0 parent=django-heroku
2022-07-19 17:03:32 [info ] init johnnydist [johnnydep.lib] dist=django parent=django-heroku
2022-07-19 17:03:37 [info ] init johnnydist [johnnydep.lib] dist=psycopg2 parent=django-heroku
2022-07-19 17:03:45 [warning ] Created temporary directory: /private/var/folders/0t/p6l6_9qd15bb9qx6bq2mrt1r0000gn/T/pip-ephem-wheel-cache-q2agslxa
....
Notes:
1.) I stopped after the first match (possibly there are more dependencies).
2.) I dont know if it is sufficient to put psycopg2-binary at the beginning of your requirements.txt, to prevent psycopg2 needed to get installed.
Deleting "django-heroku" from requirements.txt and also removing it from settings.py file solved my issue
I am rather new to Docker and I am trying to build the following image on my macos Monterey:
ARG IMAGE_TAG=3.10.0-slim-bullseye
FROM python:${IMAGE_TAG}
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get autoremove -y \
&& apt-get install -y \
gcc g++ \
# Needed for pygrib on osx
# libeccodes-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip \
&& pip install pygrib==2.1.4 \
But it does not work unless I uncomment the libeccodes-dev line.
I installed eccodes as brew install eccodes and I am in a conda environment where I ran conda install -c conda-forge eccodes and also tried pip install pygrib, but nothing seems to work.
I keep getting the following error when trying to build, complaining about eccodes not being there:
=> ERROR [3/3] RUN pip install --upgrade pip && pip install pygrib==2.1.4 14.8s
------
> [3/3] RUN pip install --upgrade pip && pip install pygrib==2.1.4:
#6 1.093 Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (21.2.4)
#6 1.484 Collecting pip
#6 1.549 Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
#6 1.890 Installing collected packages: pip
#6 1.890 Attempting uninstall: pip
#6 1.891 Found existing installation: pip 21.2.4
#6 1.966 Uninstalling pip-21.2.4:
#6 2.105 Successfully uninstalled pip-21.2.4
#6 2.713 Successfully installed pip-22.1.2
#6 2.713 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#6 3.024 Collecting pygrib==2.1.4
#6 3.081 Downloading pygrib-2.1.4.tar.gz (21.8 MB)
#6 6.127 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.8/21.8 MB 6.9 MB/s eta 0:00:00
#6 6.484 Installing build dependencies: started
#6 11.90 Installing build dependencies: finished with status 'done'
#6 11.90 Getting requirements to build wheel: started
#6 12.03 Getting requirements to build wheel: finished with status 'done'
#6 12.03 Preparing metadata (pyproject.toml): started
#6 12.14 Preparing metadata (pyproject.toml): finished with status 'done'
#6 12.28 Collecting numpy
#6 12.31 Using cached numpy-1.23.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.9 MB)
#6 12.39 Collecting pyproj
#6 12.40 Downloading pyproj-3.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.8 MB)
#6 13.66 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.8/5.8 MB 4.6 MB/s eta 0:00:00
#6 13.70 Collecting certifi
#6 13.95 Downloading certifi-2022.6.15-py3-none-any.whl (160 kB)
#6 13.97 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 160.2/160.2 kB 11.7 MB/s eta 0:00:00
#6 13.97 Building wheels for collected packages: pygrib
#6 13.98 Building wheel for pygrib (pyproject.toml): started
#6 14.68 Building wheel for pygrib (pyproject.toml): finished with status 'error'
#6 14.68 error: subprocess-exited-with-error
#6 14.68
#6 14.68 × Building wheel for pygrib (pyproject.toml) did not run successfully.
#6 14.68 │ exit code: 1
#6 14.68 ╰─> [29 lines of output]
#6 14.68 eccodes not found, build may fail...
#6 14.68 running bdist_wheel
#6 14.68 running build
#6 14.68 running build_py
#6 14.68 creating build
#6 14.68 creating build/lib.linux-aarch64-cpython-310
#6 14.68 creating build/lib.linux-aarch64-cpython-310/pygrib
#6 14.68 copying src/pygrib/__init__.py -> build/lib.linux-aarch64-cpython-310/pygrib
#6 14.68 running build_ext
#6 14.68 cythoning src/pygrib/_pygrib.pyx to src/pygrib/_pygrib.c
#6 14.68 /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-ewf87o4j/pygrib_0cec9ea4e92e455fbd34ba265ffd15b2/src/pygrib/_pygrib.pyx
#6 14.68 tree = Parsing.p_module(s, pxd, full_module_name)
#6 14.68 building 'pygrib._pygrib' extension
#6 14.68 creating build/temp.linux-aarch64-cpython-310
#6 14.68 creating build/temp.linux-aarch64-cpython-310/src
#6 14.68 creating build/temp.linux-aarch64-cpython-310/src/pygrib
#6 14.68 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.10 -I/tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include -c src/pygrib/_pygrib.c -o build/temp.linux-aarch64-cpython-310/src/pygrib/_pygrib.o
#6 14.68 In file included from /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1948,
#6 14.68 from /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
#6 14.68 from /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
#6 14.68 from src/pygrib/_pygrib.c:698:
#6 14.68 /tmp/pip-build-env-c9rf_j3a/overlay/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#6 14.68 17 | #warning "Using deprecated NumPy API, disable it with " \
#6 14.68 | ^~~~~~~
#6 14.68 src/pygrib/_pygrib.c:708:10: fatal error: grib_api.h: No such file or directory
#6 14.68 708 | #include "grib_api.h"
#6 14.68 | ^~~~~~~~~~~~
#6 14.68 compilation terminated.
#6 14.68 error: command '/usr/bin/gcc' failed with exit code 1
#6 14.68 [end of output]
#6 14.68
#6 14.68 note: This error originates from a subprocess, and is likely not a problem with pip.
#6 14.68 ERROR: Failed building wheel for pygrib
#6 14.68 Failed to build pygrib
#6 14.68 ERROR: Could not build wheels for pygrib, which is required to install pyproject.toml-based projects
------
executor failed running [/bin/sh -c pip install --upgrade pip && pip install pygrib==2.1.4]: exit code: 1
However, if I pip install and import pygrib in the same conda environment (without Docker), it succeeds with no issues, meaning that eccodes is actually correctly installed.
Also, the image can be built successfully from any computer running Linux.
I am a bit confused by this behaviour, any idea on how to work around this would be very much appreciated.
I'm having problem building Docker image from aws-mwaa-local-runner repository (using their release v2.0.2). Apparently it has problem with Flask-OpenID 1.2.5 (see output below) but I'm lost as to how to resolve it.
For the record, I tried this with Docker for Windows version 20.10.12, Ubuntu distro running with Windows Subsystem for Linux version 2, Kernel version 5.10.16.
=> [ 7/13] RUN chmod u+x /bootstrap.sh && /bootstrap.sh
...
#11 67.25 Collecting Flask-OpenID<2,>=1.2.5
#11 67.30 Downloading Flask-OpenID-1.2.5.tar.gz (43 kB)
#11 67.32 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.4/43.4 KB 3.2 MB/s eta 0:00:00
#11 67.33 Preparing metadata (setup.py): started
#11 67.51 Preparing metadata (setup.py): finished with status 'error'
#11 67.52 error: subprocess-exited-with-error
#11 67.52
#11 67.52 × python setup.py egg_info did not run successfully.
#11 67.52 │ exit code: 1
#11 67.52 ╰─> [1 lines of output]
#11 67.52 error in Flask-OpenID setup command: use_2to3 is invalid.
#11 67.52 [end of output]
#11 67.52
#11 67.52 note: This error originates from a subprocess, and is likely not a problem with pip.
#11 67.52 error: metadata-generation-failed
#11 67.52
#11 67.52 × Encountered error while generating package metadata.
#11 67.52 ╰─> See above for output.
#11 67.52
#11 67.52 note: This is an issue with the package mentioned above, not pip.
#11 67.52 hint: See above for details.
------
executor failed running [/bin/sh -c chmod u+x /bootstrap.sh && /bootstrap.sh]: exit code: 1
For the record, I was able to solve this issue by changing Flask-OpenID version in /docker/config/requirements.txt and /docker/config/constraints.txt from 1.2.5 to 1.3.0 and finished building the image successfully.
I am trying to dockerize a Django app with postgres:13.3-alpine and python 3.8.11-slim
Here are the contents of my Dockerfile:
FROM python:3.8.11-slim
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY . /code/
RUN pip install -r requirements.txt
docker-compose.yml:
version: "3"
services:
web:
build: .
command: python backend/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
db:
image: postgres:13.3-alpine
You can find my error below:
#9 13.12 ERROR: Command errored out with exit status 1:
#9 13.12 command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vftamw8l/psycopg2_a4b7534c24454475bc6e8699e7fd9f92/setup.py'"'"'; _file='"'"'/tmp/pip-install-vftamw8l/psycopg2_a4b7534c24454475bc6e8699e7fd9f92/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file_, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-jnd2mp66
#9 13.12 cwd: /tmp/pip-install-vftamw8l/psycopg2_a4b7534c24454475bc6e8699e7fd9f92/
#9 13.12 Complete output (23 lines):
#9 13.12 running egg_info
#9 13.12 creating /tmp/pip-pip-egg-info-jnd2mp66/psycopg2.egg-info
#9 13.12 writing /tmp/pip-pip-egg-info-jnd2mp66/psycopg2.egg-info/PKG-INFO
#9 13.12 writing dependency_links to /tmp/pip-pip-egg-info-jnd2mp66/psycopg2.egg-info/dependency_links.txt
#9 13.12 writing top-level names to /tmp/pip-pip-egg-info-jnd2mp66/psycopg2.egg-info/top_level.txt
#9 13.12 writing manifest file '/tmp/pip-pip-egg-info-jnd2mp66/psycopg2.egg-info/SOURCES.txt'
#9 13.12
#9 13.12 Error: pg_config executable not found.
#9 13.12
#9 13.12 pg_config is required to build psycopg2 from source. Please add the directory
#9 13.12 containing pg_config to the $PATH or specify the full executable path with the
#9 13.12 option:
#9 13.12
#9 13.12 python setup.py build_ext --pg-config /path/to/pg_config build ...
#9 13.12
#9 13.12 or with the pg_config option in 'setup.cfg'.
#9 13.12
#9 13.12 If you prefer to avoid building psycopg2 from source, please install the PyPI
#9 13.12 'psycopg2-binary' package instead.
#9 13.12
#9 13.12 For further information please check the 'doc/src/install.rst' file (also at
#9 13.12 <https://www.psycopg.org/docs/install.html>).
#9 13.12
#9 13.12 ----------------------------------------
#9 13.12 WARNING: Discarding https://files.pythonhosted.org/packages/aa/8a/7c80e7e44fb1b4277e89bd9ca509aefdd4dd1b2c547c6f293afe9f7ffd04/psycopg2-2.9.1.tar.gz#sha256=de5303a6f1d0a7a34b9d40e4d3bef684ccc44a49bbe3eb85e3c0bffb4a131b7c (from https://pypi.org/simple/psycopg2/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#9 13.13 ERROR: Could not find a version that satisfies the requirement psycopg2==2.9.1 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1)
#9 13.13 ERROR: No matching distribution found for psycopg2==2.9.1
------
executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
ERROR: Service 'web' failed to build : Build failed
Tried many fixes already from various answers from stackoverflow like the ones down, but nothing seemed to work for me:
Error: pg_config executable not found when installing psycopg2 on Alpine in Docker
Failing to install psycopg2-binary on new docker container
In case someone needs, I solved this issue by using a different docker image. FROM python:3.9