简体   繁体   中英

Failed to build a docker container with pyproj

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM