无法使用pyproj构建docker容器

如何解决无法使用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'

我看到了两种可能的解决方案:

  1. 安装到其他目​​录(我会尝试使用主目录)
  2. 在运行pip之前,通过设置USER root以root用户身份运行命令

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?