2

I'm running Django rest api with the django 3.2 on GCPUbuntu 20.04.5 LTS (GNU/Linux 5.15.0-1025-gcp x86_64). I'm getting an error when i run my docker containers. I need to use GDAL in one of my project modules. I'm pasting log from one the the containers my-api-webserver. There are 2 other containers running worker and scheduler servers which display the same errors.

gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'

The following is the detailed trace :

my-api-webserver |   error: subprocess-exited-with-error
my-api-webserver |   
my-api-webserver |   × python setup.py egg_info did not run successfully.
my-api-webserver |   │ exit code: 1
my-api-webserver |   ╰─> [125 lines of output]
my-api-webserver |       running egg_info
my-api-webserver |       creating /tmp/pip-pip-egg-info-2zpklao8/GDAL.egg-info
my-api-webserver |       writing /tmp/pip-pip-egg-info-2zpklao8/GDAL.egg-info/PKG-INFO
my-api-webserver |       writing dependency_links to /tmp/pip-pip-egg-info-2zpklao8/GDAL.egg-info/dependency_links.txt
my-api-webserver |       writing requirements to /tmp/pip-pip-egg-info-2zpklao8/GDAL.egg-info/requires.txt
my-api-webserver |       writing top-level names to /tmp/pip-pip-egg-info-2zpklao8/GDAL.egg-info/top_level.txt
my-api-webserver |       writing manifest file '/tmp/pip-pip-egg-info-2zpklao8/GDAL.egg-info/SOURCES.txt'
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 121, in fetch_config
my-api-webserver |           p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
my-api-webserver |           self._execute_child(args, executable, preexec_fn, close_fds,
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
my-api-webserver |           raise child_exception_type(errno_num, err_msg, err_filename)
my-api-webserver |       FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 205, in get_gdal_config
my-api-webserver |           return fetch_config(option, gdal_config=self.gdal_config)
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 124, in fetch_config
my-api-webserver |           raise gdal_config_error(e)
my-api-webserver |       __main__.gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 121, in fetch_config
my-api-webserver |           p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
my-api-webserver |           self._execute_child(args, executable, preexec_fn, close_fds,
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
my-api-webserver |           raise child_exception_type(errno_num, err_msg, err_filename)
my-api-webserver |       FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 212, in get_gdal_config
my-api-webserver |           return fetch_config(option)
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 124, in fetch_config
my-api-webserver |           raise gdal_config_error(e)
my-api-webserver |       __main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "<string>", line 2, in <module>
my-api-webserver |         File "<pip-setuptools-caller>", line 34, in <module>
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 414, in <module>
my-api-webserver |           setup(**setup_kwargs)
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 87, in setup
my-api-webserver |           return distutils.core.setup(**attrs)
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 185, in setup
my-api-webserver |           return run_commands(dist)
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
my-api-webserver |           dist.run_commands()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
my-api-webserver |           self.run_command(cmd)
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 1208, in run_command
my-api-webserver |           super().run_command(command)
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
my-api-webserver |           cmd_obj.run()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 308, in run
my-api-webserver |           self.find_sources()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 316, in find_sources
my-api-webserver |           mm.run()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 560, in run
my-api-webserver |           self.add_defaults()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 597, in add_defaults
my-api-webserver |           sdist.add_defaults(self)
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/command/sdist.py", line 106, in add_defaults
my-api-webserver |           super().add_defaults()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 252, in add_defaults
my-api-webserver |           self._add_defaults_ext()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
my-api-webserver |           build_ext = self.get_finalized_command('build_ext')
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 305, in get_finalized_command
my-api-webserver |           cmd_obj.ensure_finalized()
my-api-webserver |         File "/usr/local/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
my-api-webserver |           self.finalize_options()
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 275, in finalize_options
my-api-webserver |           self.gdaldir = self.get_gdal_config('prefix')
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 218, in get_gdal_config
my-api-webserver |           raise gdal_config_error(traceback_string + '\n' + msg)
my-api-webserver |       __main__.gdal_config_error: Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 121, in fetch_config
my-api-webserver |           p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
my-api-webserver |           self._execute_child(args, executable, preexec_fn, close_fds,
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
my-api-webserver |           raise child_exception_type(errno_num, err_msg, err_filename)
my-api-webserver |       FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 205, in get_gdal_config
my-api-webserver |           return fetch_config(option, gdal_config=self.gdal_config)
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 124, in fetch_config
my-api-webserver |           raise gdal_config_error(e)
my-api-webserver |       gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 121, in fetch_config
my-api-webserver |           p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
my-api-webserver |           self._execute_child(args, executable, preexec_fn, close_fds,
my-api-webserver |         File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
my-api-webserver |           raise child_exception_type(errno_num, err_msg, err_filename)
my-api-webserver |       FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
my-api-webserver |       
my-api-webserver |       During handling of the above exception, another exception occurred:
my-api-webserver |       
my-api-webserver |       Traceback (most recent call last):
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 212, in get_gdal_config
my-api-webserver |           return fetch_config(option)
my-api-webserver |         File "/tmp/pip-install-am7iveqp/gdal_636d6d66a9b14d6e9183a48706abd53e/setup.py", line 124, in fetch_config
my-api-webserver |           raise gdal_config_error(e)
my-api-webserver |       gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
my-api-webserver |       
my-api-webserver |       Could not find gdal-config. Make sure you have installed the GDAL native library and development headers.
my-api-webserver |       [end of output]
my-api-webserver |   
my-api-webserver |   note: This error originates from a subprocess, and is likely not a problem with pip.
my-api-webserver | error: metadata-generation-failed
my-api-webserver | 
my-api-webserver | × Encountered error while generating package metadata.
my-api-webserver | ╰─> See above for output.
my-api-webserver | 
my-api-webserver | note: This is an issue with the package mentioned above, not pip.
my-api-webserver | hint: See above for details.

This is my docker file :

FROM python:3.8.14

RUN apt-get -y update && apt-get -y upgrade && apt-get install -y ffmpeg && apt install libgdal-dev --upgrade
RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal
RUN export C_INCLUDE_PATH=/usr/include/gdal
COPY wait-for-it.sh /wait-for-it.sh

# Copy any files over
COPY entrypoint.sh /entrypoint.sh

# Copy any files over
COPY bootstrap_development_data.sh /bootstrap_development_data.sh

# Change permissions
RUN chmod +x /entrypoint.sh
RUN chmod +x /bootstrap_development_data.sh
RUN chmod +x /wait-for-it.sh
RUN groupadd -r docker && useradd -r -g docker earthling
RUN chown -R earthling /root/


ENTRYPOINT ["/entrypoint.sh"]

COPY requirements.txt /requirements.txt
RUN pip3 install --upgrade pip setuptools wheel
RUN pip3 install -r /requirements.txt
RUN yes | pip uninstall django-rq-scheduler
RUN yes | pip install -U django-rq-scheduler

VOLUME ["/opt/my-api"]

EXPOSE 80


CMD ["python", "manage.py", "runserver", "0.0.0.0:80"]

I have separately also done the following :

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin --upgrade
sudo apt remove gdal-bin
sudo apt install libgdal-dev --upgrade
sudo apt remove libgdal-dev

After the above, when i run :

gdal-config --version 
Result : 3.3.2

This is my requirements.txt

aioredis==1.3.1
appdirs==1.4.4
asgiref==3.5.2
async-timeout==4.0.2
attrs==22.1.0
autobahn==22.7.1
Automat==20.2.0
bandit==1.7.4
babel==2.11.0
beautifulsoup4==4.11.1
boto3==1.26.41
botocore==1.29.41
certifi==2022.9.14
cffi==1.15.1
channels==3.0.5
channels-redis==3.4.1
chardet==5.0.0
click==8.1.3
colorama==0.4.5
colormath==3.0.0
constantly==15.1.0
coverage==6.4.4
croniter==1.3.7
cryptography==38.0.1
daphne==3.0.2
decorator==5.1.1
Django==3.2
django-amazon-ses==4.0.1
django-extra-views==0.14.0
django-appconf==1.0.5
django-cursor-pagination==0.2.0
django-extensions==3.2.1
django-imagekit==4.1.0
django-media-fixtures-next==1.0.1
django-model-utils==4.2.0
django-modeltranslation==0.18.4
django-nose==1.4.7
django-ordered-model==3.6
django-positions==0.6.0
django-proxy==1.2.1
django-redis==5.2.0
django-replicated==2.7
django-rq==2.5.1
django-rq-scheduler==2022.9
django-storages==1.13.1
django-utils-six==2.0
djangorestframework==3.13.1
django-widget-tweaks==1.4.12
django-haystack==3.2.1
django-treebeard==4.5.1
django-tables2==2.4.1
django-extensions==3.2.1
django-phone-verify==2.0.1
dparse==0.6.0
easy-thumbnails==2.8.4
Faker==12.0.1
feedparser==6.0.10
ffmpy==0.3.0
filelock==3.8.0
funcy==1.17
factory-boy>=3.2,<3.3
gitdb==4.0.9
GitPython==3.1.27
halo==0.0.31
hiredis==2.0.0
hyperlink==21.0.0
idna==3.4
incremental==21.3.0
jmespath==1.0.1
langdetect==1.0.9
log-symbols==0.0.14
mixer==7.2.2
msgpack==1.0.4
mysqlclient==2.1.1
natsort==8.2.0
networkx==2.8.6
nose==1.3.7
nose-exclude==0.5.0
numpy==1.23.3
onesignal-sdk==2.0.0
opencv-python==4.6.0.66
packaging==21.3
pathtools==0.1.2
pbr==5.10.0
pilkit==2.0
Pillow==9.2.0
pinocchio==0.4.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
PyJWT==2.4.0
pyOpenSSL==22.0.0
pyparsing==3.0.9
pytest-cov>=2.12,<3.1
python-dateutil==2.8.2
python-dotenv==0.21.0
python-magic==0.4.27
pytz==2022.2.1
PyYAML==6.0
purl==1.6
redis==4.3.4
requests==2.28.1
requests-file==1.5.1
rest-framework-generic-relations==2.1.0
rq==1.11.0
rq-scheduler==0.11.0
s3transfer==0.6.0
safety==2.1.1
sentry-sdk==1.9.8
service-identity==21.1.0
sgmllib3k==1.0.0
shutilwhich==1.1.0
six==1.16.0
smmap==5.0.0
soupsieve==2.3.2.post1
spectra==0.0.11
spinners==0.0.24
sqlparse==0.4.2
stevedore==4.0.0
stripe==4.1.0
sorl-thumbnail==12.9.0
termcolor==2.0.1
text-unidecode==1.3
tox>=3.23,<3.26
tldextract==3.3.1
toml==0.10.2
txaio==22.2.1
typing_extensions==4.3.0
uritools==4.0.0
url-normalize==1.4.3
urlextract==1.6.0
urllib3==1.26.12
watchdog==2.1.9
webpreview==1.7.2
whitenoise==6.2.0
zipp==3.8.1
zope.interface==5.4.0
django-cacheops==6.1.0
onesignal==0.1.3
onesignal-client==0.0.2
isort>=5.9,<5.11
flake8>=6.0.0
django-environ==0.9.0
mock==4.0.3
GDAL==3.3.2
setuptools==57.5.0


#commerce packages - development
# Excluding package already included above)

Werkzeug>=1.0,<2.1
django-debug-toolbar>=2.2,<3.6
psycopg2-binary>=2.8,<2.10

#Social-commerce packages - sandbox
Whoosh>=2.7,<2.8
pysolr==3.9.0
uWSGI>=2.0.19,<2.1

# Linting
flake8-debugger==4.1.2

# Helpers
pyprof2calltree>=1.4,<1.5
ipdb>=0.13,<0.14
ipython>=7.12,<9

# Country data
pycountry

#cli-based
colorlog==6.7.0
halo==0.0.31
requests==2.28.1
click==8.1.3

Help appreciated !

Earthling
  • 83
  • 3
  • 13

0 Answers0