如何解决无法使用pyproj构建docker容器
我正在尝试构建一个应该包含pyproj软件包的docker容器。我宁愿呆在python:3-alpine
上,因为到目前为止,这是我设法安装python mariaDB客户端的唯一方法(因此是其他docker命令)。
我的 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
控制台输出
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,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
解决方法
从错误来看,这似乎是权限问题。
PermissionError: [Errno 13] Permission denied: '/usr/bin/proj'
我看到了两种可能的解决方案:
- 安装到其他目录(我会尝试使用主目录)
- 在运行pip之前,通过设置
USER root
以root用户身份运行命令
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。