0

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 facing a problem when I run docker-compose command. The trace points to Gdal.

Currently,

gdal-config --version
2.4.2

I have done the following :

pip3 install GDAL==2.4.2
pip3 install setuptools==57.5.0
pip3 instal numpy==1.24.2

The above package versions were set after reading many stack posts:

GDAL version from pip should be the same as the one 'gdal-config--version'

Downgrade setuptools to 57.5.0 or lower.

However its not working. Here is the detailed trace:

Collecting GDAL==2.4.2
  Downloading GDAL-2.4.2.tar.gz (564 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 564.8/564.8 kB 174.0 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      WARNING: numpy not available!  Array support will not be enabled
      /usr/local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'use_2to3_fixers'
        warnings.warn(msg)
      /usr/local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'use_2to3_exclude_fixers'
        warnings.warn(msg)
      error in GDAL setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
ERROR: Service 'webserver' failed to build: The command '/bin/sh -c pip3 install -r /requirements.txt' returned a non-zero code: 1

Help appreciated !

EDIT: I deleted all containers with

docker system prune

docker volume prune

Re-built the images using docker-compose up , now the error has changed to

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

pip3 --version shows 23.0.1.

However i do get warning regarding pip in the stack trace:

WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.

I have a requirements.txt which gets used during the build stage. Here it is.I anyways always run pip3 install -r requirements.txt before building the images so it just collects the packages. Here is the file.

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
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==2.4.2
numpy==1.24.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

#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

EDIT as on 09/03/2023: I am posting a new question as a change in installation method of gdal has changed the error itself :

Django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library ,Is GDAL installed?

Earthling
  • 83
  • 3
  • 13
  • First downgrade setuptools, then `pip install GDAL` – phd Mar 08 '23 at 11:18
  • https://stackoverflow.com/search?q=%5Bpip%5D+error+in+setup+command+use_2to3+is+invalid – phd Mar 08 '23 at 11:19
  • I did mention in I already downgraded to 57.5.0. Upon your comment I did further downgrade it to 51.2.0 and gdal remained at 2.4.2. The error still stays. – Earthling Mar 08 '23 at 11:51
  • "*I did mention in I already downgraded to 57.5.0*" You did it after `pip install GDAL`, it must be before. – phd Mar 08 '23 at 12:19
  • Sure. will try this out. – Earthling Mar 08 '23 at 12:41
  • Please [edit] and add the text output of `pip3 --version`, `pip3 list`, check that `setuptools` is of a proper (lower enough) version. Then `pip3 install GDAL==2.4.2`. – phd Mar 08 '23 at 12:43
  • Have edited the question. I'm running nuts. the error has changed to gdal config not found. Have updated the question. – Earthling Mar 08 '23 at 13:07
  • "*gdal config not found*" That perhaps the result of purging everything; now you need to install https://gdal.org/download.html#binaries . As for `requirements.txt` — `pip3 install setuptools==57.5.0` must be run before `pip3 install -r requirements.txt`. It's not enough to have `setuptools==57.5.0` in `requirements.txt`; the version will not be installed untill the entire `requirements.txt` is processed and at the time GDAL installation will already be failing because of the wrong `setuptools` version. – phd Mar 08 '23 at 13:26
  • regarding the "gdal config not found": I have already run sudo apt-get install gdal-bin --upgrade and sudo apt install libgdal-dev. Wouldnt that be enough? – Earthling Mar 08 '23 at 13:38
  • No idea. I know nothing about GDAL. I only answered about error "*use_2to3 is invalid*"; the solution is `pip install setuptools < 58` – phd Mar 08 '23 at 13:56
  • I attempted the following to use a legacy setup.py and install gdal separately : pip3 install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}') --global-option=build_ext --global-option="-I/usr/include/gdal" https://stackoverflow.com/questions/38630474/error-while-installing-gdal/44051123#44051123 . It recognized the version to be 2.4 instead of 2.4.2 and installed it. But the error(main.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config') remains. The issue is i believe not with setup tools. – Earthling Mar 09 '23 at 10:22
  • @phd Question updated just now. – Earthling Mar 09 '23 at 10:46

0 Answers0