CANPOPY LINUX的可以安装ProJ 8.0.0

发布于 2025-02-03 09:56:06 字数 190 浏览 5 评论 0原文

我正在尝试在Ubuntu上安装CATTOPY,并需要安装Proj V8.0.0用于造型的二进制文件。但是,当我尝试apt-get install proj-bin时,我只能获得proj v6.3.1。如何安装最新的(或至少v8.0.0)proj?

I am trying to install Cartopy on Ubuntu and need to install proj v8.0.0 binaries for Cartopy. However when I try to apt-get install proj-bin I can only get proj v6.3.1. How do I install the latest (or at least v8.0.0) proj for cartopy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼眸印温柔 2025-02-10 09:56:06

我在这里回答自己的问题,部分是为了帮助他人解决这个问题,部分是作为我自己的档案,所以如果我再次遇到这个问题,我知道如何解决此问题。我花了一段时间试图弄清楚它,并编写了详细的说明,因此请参阅下面:

安装CATTOPY是一个巨大的痛苦,我发现使用Conda是一个非常糟糕的主意(它已经砖砌了(它已经做到了,python)对我来说多次)

此安装适用于Linux。

步骤0。更新APT:

apt update

步骤1。SthernGeos:

运行以下命令以安装Geos:

apt-get install libgeos-dev

如果不这样做,请使用以下所有文件:

apt-get install libgeos-dev libgeos++-dev libgeos-3.8.0 libgeos-c1v5 libgeos-doc

步骤2。Sthernproj依赖项:

  • 安装cmake:install
apt install cmake
  • sqlite: install sqlite3:
apt install sqlite3
  • install curl: DevLopment软件包:
apt install curl && apt-get install libcurl4-openssl-dev

步骤3。安装ProJ

尝试apt-get以防万一它有效:

不幸的是,Cartopy需要ProJ V8.0.0作为最小值.3.1

仅供参考,以防万一更改,这是从apt安装proj的命令:

apt-get install proj-bin

我很确定这就是您所需要的,但是如果不是,此命令将安装剩余的proj文件:

apt-get install proj-bin libproj-dev proj-data

要删除上面的proj文件安装,运行:

apt-get remove proj-bin

或:

apt-get remove proj-bin libproj-dev proj-data

从源构建proj,

因此,如果以上命令不起作用(截至2022/4/8),请按照以下说明从 source

  • 转到您的安装文件夹并下载proj-9.0.0(或任何版本的带有任何版本的版本proj-xxxtar.gz):
wget https://download.osgeo.org/proj/proj-9.0.0.tar.gz 
  • 提取tar.gz文件:
tar -xf proj-9.0.0.tar.gz
  • CD到文件夹中:
cd proj-9.0.0
  • 将构建文件夹和CD放入其中:
mkdir build && cd build
  • 运行(这可能需要一段时间):
cmake ..
cmake --build .
cmake --build . --target install
  • 运行以确保安装所有已安装的所有内容正确:
ctest

测试命令在一个测试中失败了(19 -NKG),但否则很好。

中找到所需的文件

  • 目录
cp ./bin/* /bin
  • 您应该在./ bin
cp ./lib/* /lib

使用PIP安装CATTOPY:

pip install cartopy

执行此操作后,我的摄影作品仍然无法正常工作。我下周回家去工作,回来了,突然之间它正在工作,所以也许尝试重新启动

I'm answering my own question here partly to help others with this problem, and partly as an archive for myself so I know how to fix this issue if I come across it again. I spent quite a while trying to figure it out, and wrote detailed instructions, so see below:

Installing cartopy is a huge pain, and I've found using conda to be a very bad idea (it has bricked itself and python along with it multiple times for me)

THIS INSTALLATION IS FOR LINUX.

Step 0. Update apt:

apt update

Step 1. Install GEOS:

Run the following command to install GEOS:

apt-get install libgeos-dev

In case that doesn't do it, install all files with this:

apt-get install libgeos-dev libgeos++-dev libgeos-3.8.0 libgeos-c1v5 libgeos-doc

Step 2. Install proj dependencies:

  • Install cmake:
apt install cmake
  • Install sqlite3:
apt install sqlite3
  • Install curl devlopment package:
apt install curl && apt-get install libcurl4-openssl-dev

Step 3. Install Proj

Trying apt-get just in case it works:

Unfortunately, cartopy requires proj v8.0.0 as a minimum, but if you install proj using apt you can only install proj v6.3.1

Just for reference in case anything changes, this is the command to install proj from apt:

apt-get install proj-bin

I'm fairly sure this is all you need, but in case it's not, this command will install the remaining proj files:

apt-get install proj-bin libproj-dev proj-data

To remove the above installation, run:

apt-get remove proj-bin

or:

apt-get remove proj-bin libproj-dev proj-data

Building Proj from source

So if the above commands don't work (it's not working as of 2022/4/8), then follow the below instructions to install proj from source:

  • Go to your install folder and download proj-9.0.0 (or any version with proj-x.x.x.tar.gz):
wget https://download.osgeo.org/proj/proj-9.0.0.tar.gz 
  • Extract the tar.gz file:
tar -xf proj-9.0.0.tar.gz
  • cd into the folder:
cd proj-9.0.0
  • Make a build folder and cd into it:
mkdir build && cd build
  • Run (this may take a while):
cmake ..
cmake --build .
cmake --build . --target install
  • Run to make sure everything installed correctly:
ctest

The test command failed on one test for me (19 - nkg), but otherwise was fine.

You should find the required files in the ./bin directory

Finally:

  • Move binaries to the /bin directory:
cp ./bin/* /bin
  • As per Justino, you may also need to move the libraries:
cp ./lib/* /lib

Now after all this, you can finally install cartopy with pip:

pip install cartopy

After doing this, my cartopy still wasn't working. I went home to work on this next week, came back, and all of a sudden it was working so maybe try restarting

星軌x 2025-02-10 09:56:06

图书馆应手动复制
sudo cp ./lib/*/lib
这对我有用

The libraries should be copied manually
sudo cp ./lib/* /lib
This works for me

墨落画卷 2025-02-10 09:56:06

以下是多阶段 Dockerfile我组合在一起,用于使用大气数据和机器学习。

# syntax=docker/dockerfile:1

# Description:
# Multistage Dockerfile for working with the SEVIR dataset and other atmospheric
# data formats for analysis, processing, and Machine Learning.

# Example:
# - docker build -t $USER/sevir . 
# - docker run -it -p 8888:8888 --gpus all --volume $PATH_TO_SEVIR:/home/vscode $USER/sevir

# TODD:
# install ffmpeg for video processing needed for matplotlib animations
# sudo apt install ffmpeg    

FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 AS base
USER root

WORKDIR /
SHELL ["/bin/bash","-c"]
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get install -y --no-install-recommends \
    python3.10 \
    python3.10-venv \
    libgeos3.10.2 \
    libgdal30 \
    && rm -rf /var/lib/apt/lists/* \
    && python3.10 -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
USER 1001

# =====================================================================================================================
# Compiler Stage; this will be omitted from the final image
# =====================================================================================================================
FROM base AS compiler
USER root

WORKDIR /
SHELL ["/bin/bash","-c"]
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
    wget \
    gcc   \
    g++    \
    cmake   \
    gfortran \
    python3.10-dev \
    build-essential \
    # see: https://github.com/OSGeo/PROJ/blob/master/Dockerfile
    zlib1g-dev libsqlite3-dev sqlite3 libcurl4-gnutls-dev libtiff5-dev libsqlite3-0 libtiff5 \
    libgdal-dev libatlas-base-dev libhdf5-serial-dev \
    && rm -rf /var/lib/apt/lists/*

USER 1001

# =====================================================================================================================
# EcCodes is a library for decoding and encoding grib files.
# =====================================================================================================================
FROM compiler AS eccodes
USER root
ARG ECCODES="eccodes-2.24.2-Source" 
ARG ECCODES_DIR="/usr/include/eccodes"

WORKDIR /tmp
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN wget -c --progress=dot:giga \
    https://confluence.ecmwf.int/download/attachments/45757960/${ECCODES}.tar.gz  -O - | tar -xz -C . --strip-component=1 

WORKDIR /tmp/build
SHELL ["/bin/bash","-c"]
RUN cmake -DCMAKE_INSTALL_PREFIX="${ECCODES_DIR}" -DENABLE_PNG=ON .. \
    && make -j"$(nproc)" \
    && make install

USER 1001

# =====================================================================================================================
# PROJ is a library for coordinate transformations, and is a requirement for cartopy.
# =====================================================================================================================
FROM compiler AS proj
USER root

WORKDIR /proj
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN wget -c --progress=dot:giga \
    https://github.com/OSGeo/PROJ/archive/refs/tags/9.0.1.tar.gz  -O - | tar -xz -C . --strip-component=1 

WORKDIR /proj/build
SHELL ["/bin/bash","-c"]
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \
    && make -j"$(nproc)" \
    && make install

USER 1001

# =====================================================================================================================
# Cartopy is a python library for plotting data on maps.
# =====================================================================================================================
FROM proj AS cartopy
USER root

SHELL ["/bin/bash","-c"]
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
    python3.10-dev \
    && rm -rf /var/lib/apt/lists/*
# hadolint ignore=DL3013
RUN python3.10 -m pip install --upgrade pip --no-cache-dir && python3.10 -m pip install --no-cache-dir \
    Cartopy==0.21.1 \
    matplotlib==3.7.2

USER 1001

# =====================================================================================================================
# Final Image
# =====================================================================================================================
FROM base AS lunch-box
USER root
ARG USERNAME=vscode 
ARG USER_UID=1000
ARG USER_GID=$USER_UID

WORKDIR /tmp/sevir
SHELL ["/bin/bash","-c"]
# hadolint ignore=DL3008
RUN groupadd --gid $USER_GID $USERNAME \
    && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
    && chown -R $USER_UID:$USER_GID /opt/venv

ENV ECCODES_DIR=/usr/include/eccodes
COPY --from=eccodes --chown=$USER_UID:$USER_GID $ECCODES_DIR $ECCODES_DIR
COPY --from=cartopy --chown=$USER_UID:$USER_GID /opt/venv /opt/venv
# - install requirements that arn't in the requirements.txt and torch for caching
RUN python3.10 -m pip install --no-cache-dir \
    torch==2.0.1 \
    cfgrib==0.9.10.4 \
    notebook==6.5.4 \
    eccodes==1.6.0 
# - install the package and dependencies
COPY src/ src/
COPY setup.py setup.py
COPY pyproject.toml pyproject.toml
RUN python3.10 -m pip install . --no-cache-dir && rm -rf /tmp/*

USER $USERNAME
ARG HOME=/home/$USERNAME
WORKDIR $HOME
COPY --chown=$USER_UID:$USER_GID notebooks/ examples/
VOLUME $HOME/sevir-volume
ENV PATH_TO_SEVIR=$HOME/sevir-volume/sevir

CMD [ "jupyter", "notebook", "--ip=0.0.0.0", "--NotebookApp.token=''", "--NotebookApp.password=''", "--no-browser" ]

Below is a Multistage Dockerfile I put together for working with atmospheric data and machine learning.

# syntax=docker/dockerfile:1

# Description:
# Multistage Dockerfile for working with the SEVIR dataset and other atmospheric
# data formats for analysis, processing, and Machine Learning.

# Example:
# - docker build -t $USER/sevir . 
# - docker run -it -p 8888:8888 --gpus all --volume $PATH_TO_SEVIR:/home/vscode $USER/sevir

# TODD:
# install ffmpeg for video processing needed for matplotlib animations
# sudo apt install ffmpeg    

FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 AS base
USER root

WORKDIR /
SHELL ["/bin/bash","-c"]
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get install -y --no-install-recommends \
    python3.10 \
    python3.10-venv \
    libgeos3.10.2 \
    libgdal30 \
    && rm -rf /var/lib/apt/lists/* \
    && python3.10 -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
USER 1001

# =====================================================================================================================
# Compiler Stage; this will be omitted from the final image
# =====================================================================================================================
FROM base AS compiler
USER root

WORKDIR /
SHELL ["/bin/bash","-c"]
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
    wget \
    gcc   \
    g++    \
    cmake   \
    gfortran \
    python3.10-dev \
    build-essential \
    # see: https://github.com/OSGeo/PROJ/blob/master/Dockerfile
    zlib1g-dev libsqlite3-dev sqlite3 libcurl4-gnutls-dev libtiff5-dev libsqlite3-0 libtiff5 \
    libgdal-dev libatlas-base-dev libhdf5-serial-dev \
    && rm -rf /var/lib/apt/lists/*

USER 1001

# =====================================================================================================================
# EcCodes is a library for decoding and encoding grib files.
# =====================================================================================================================
FROM compiler AS eccodes
USER root
ARG ECCODES="eccodes-2.24.2-Source" 
ARG ECCODES_DIR="/usr/include/eccodes"

WORKDIR /tmp
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN wget -c --progress=dot:giga \
    https://confluence.ecmwf.int/download/attachments/45757960/${ECCODES}.tar.gz  -O - | tar -xz -C . --strip-component=1 

WORKDIR /tmp/build
SHELL ["/bin/bash","-c"]
RUN cmake -DCMAKE_INSTALL_PREFIX="${ECCODES_DIR}" -DENABLE_PNG=ON .. \
    && make -j"$(nproc)" \
    && make install

USER 1001

# =====================================================================================================================
# PROJ is a library for coordinate transformations, and is a requirement for cartopy.
# =====================================================================================================================
FROM compiler AS proj
USER root

WORKDIR /proj
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN wget -c --progress=dot:giga \
    https://github.com/OSGeo/PROJ/archive/refs/tags/9.0.1.tar.gz  -O - | tar -xz -C . --strip-component=1 

WORKDIR /proj/build
SHELL ["/bin/bash","-c"]
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \
    && make -j"$(nproc)" \
    && make install

USER 1001

# =====================================================================================================================
# Cartopy is a python library for plotting data on maps.
# =====================================================================================================================
FROM proj AS cartopy
USER root

SHELL ["/bin/bash","-c"]
ENV DEBIAN_FRONTEND=noninteractive
# hadolint ignore=DL3008
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
    python3.10-dev \
    && rm -rf /var/lib/apt/lists/*
# hadolint ignore=DL3013
RUN python3.10 -m pip install --upgrade pip --no-cache-dir && python3.10 -m pip install --no-cache-dir \
    Cartopy==0.21.1 \
    matplotlib==3.7.2

USER 1001

# =====================================================================================================================
# Final Image
# =====================================================================================================================
FROM base AS lunch-box
USER root
ARG USERNAME=vscode 
ARG USER_UID=1000
ARG USER_GID=$USER_UID

WORKDIR /tmp/sevir
SHELL ["/bin/bash","-c"]
# hadolint ignore=DL3008
RUN groupadd --gid $USER_GID $USERNAME \
    && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
    && chown -R $USER_UID:$USER_GID /opt/venv

ENV ECCODES_DIR=/usr/include/eccodes
COPY --from=eccodes --chown=$USER_UID:$USER_GID $ECCODES_DIR $ECCODES_DIR
COPY --from=cartopy --chown=$USER_UID:$USER_GID /opt/venv /opt/venv
# - install requirements that arn't in the requirements.txt and torch for caching
RUN python3.10 -m pip install --no-cache-dir \
    torch==2.0.1 \
    cfgrib==0.9.10.4 \
    notebook==6.5.4 \
    eccodes==1.6.0 
# - install the package and dependencies
COPY src/ src/
COPY setup.py setup.py
COPY pyproject.toml pyproject.toml
RUN python3.10 -m pip install . --no-cache-dir && rm -rf /tmp/*

USER $USERNAME
ARG HOME=/home/$USERNAME
WORKDIR $HOME
COPY --chown=$USER_UID:$USER_GID notebooks/ examples/
VOLUME $HOME/sevir-volume
ENV PATH_TO_SEVIR=$HOME/sevir-volume/sevir

CMD [ "jupyter", "notebook", "--ip=0.0.0.0", "--NotebookApp.token=''", "--NotebookApp.password=''", "--no-browser" ]
沧桑㈠ 2025-02-10 09:56:06

对于使用Red Hat Enterprise Linux 8的任何人,这就是我的工作方式:

安装依赖项:

sudo dnf install geos-devel sqlite sqlite-devel cmake libcurl-devel libtiff-devel

然后下载源:

mkdir Downloads/Proj
cd Downlods/Proj
wget https://download.osgeo.org/proj/proj-8.2.1.tar.gz
tar -xf proj-8.2.1.tar.gz 
cd proj-8.2.1/

然后配置和构建:

./configure
make
make check
sudo make install

然后在Python虚拟环境中安装摄影作品正常工作。
希望对某人有帮助。

And for anyone using Red Hat Enterprise Linux 8 here is how I did it:

Install the dependencies:

sudo dnf install geos-devel sqlite sqlite-devel cmake libcurl-devel libtiff-devel

Then download the source:

mkdir Downloads/Proj
cd Downlods/Proj
wget https://download.osgeo.org/proj/proj-8.2.1.tar.gz
tar -xf proj-8.2.1.tar.gz 
cd proj-8.2.1/

Then configure and build:

./configure
make
make check
sudo make install

Then installing Cartopy in a Python Virtual Environment worked fine.
Hope that helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文