0

I'm trying to build a docker container that should contain pyproj package. I prefer to stay with python:3-alpine since it is so far the only way I have managed to install a python mariaDB client (hence the other docker commands).

My Dockerfile

FROM python:3-alpine

RUN mkdir –m777 /usr/bin/proj
ENV PROJ_DIR=/usr

RUN apk add --no-cache build-base proj proj-dev
RUN pip install --upgrade pip && \
    pip install pyproj==2.4.0

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main openssl \
    build-base cmake musl-dev linux-headers
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing gdal-dev

RUN apk add --no-cache mariadb-dev build-base

Console output

docker build . -t dockerpython
Sending build context to Docker daemon  557.1kB
Sending build context to Docker daemon  137.5MB
Step 1/13 : FROM python:3-alpine
 ---> dc68588b1801
Step 2/13 : RUN mkdir –m777 /usr/bin/proj
 ---> Using cache
 ---> 499167715cfb
Step 3/13 : ENV PROJ_DIR=/usr
 ---> Using cache
 ---> a96f037cf53f
Step 4/13 : RUN apk add --no-cache build-base proj proj-dev
 ---> Using cache
 ---> 40e3099b6546
Step 5/13 : RUN pip install --upgrade pip &&     pip install pyproj==2.4.0
 ---> Running in e06e02c59a6c
Requirement already up-to-date: pip in /usr/local/lib/python3.9/site-packages (20.2.4)
Collecting pyproj==2.4.0
  Downloading pyproj-2.4.0.tar.gz (460 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp1pjmenku
       cwd: /tmp/pip-install-04c55e8d/pyproj
  Complete output (34 lines):
  PROJ_DIR is set, using existing proj4 installation..
  
  Traceback (most recent call last):
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-jasrw0jd/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 149, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/tmp/pip-build-env-jasrw0jd/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 130, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-jasrw0jd/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 253, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-jasrw0jd/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 236, in <module>
      ext_modules=get_extension_modules(),
    File "setup.py", line 140, in get_extension_modules
      proj_dir = get_proj_dir()
    File "setup.py", line 53, in get_proj_dir
      check_proj_version(proj_dir)
    File "setup.py", line 20, in check_proj_version
      proj_ver_bytes = subprocess.check_output(proj, stderr=subprocess.STDOUT)
    File "/usr/local/lib/python3.9/subprocess.py", line 420, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "/usr/local/lib/python3.9/subprocess.py", line 501, in run
      with Popen(*popenargs, **kwargs) as process:
    File "/usr/local/lib/python3.9/subprocess.py", line 947, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/local/lib/python3.9/subprocess.py", line 1819, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  PermissionError: [Errno 13] Permission denied: '/usr/bin/proj'
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp1pjmenku Check the logs for full command output.
The command '/bin/sh -c pip install --upgrade pip &&     pip install pyproj==2.4.0' returned a non-zero code: 1
Tars Morel
  • 61
  • 7

1 Answers1

0

Judging from the error, this looks to be a permissions issue.

PermissionError: [Errno 13] Permission denied: '/usr/bin/proj'

I see a couple of possible solutions:

  1. Install to a different directory (I would try using the home directory)
  2. Run the command as root by setting USER root before running pip
Zacx
  • 420
  • 5
  • 10
  • Thanks for the tip, but it didn't work unfortunately. I've added `USER root` without success, and installing it in home dir of `root` which is the `root` directory also didn't work. _Note that the default user is root in Docker_ (`RUN whom` returns `root`) – Tars Morel Oct 25 '20 at 10:17
  • The top answer here might help: https://stackoverflow.com/questions/25816674/pip-is-not-able-to-install-packages-correctly-permission-denied-error – Zacx Oct 25 '20 at 17:55