0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ubuntu18.04/20.04/22.04にmapnikインストール

Posted at

Ubuntu 18.04 (Python 3.6)

python3-mapnikの動作問題無し

FROM ubuntu:18.04

RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y \
    python3.6 \
    python3.6-dev \
    python-pip \
    libgdal-dev \
    gdal-bin \
    libmapnik-dev \
    python3-mapnik

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10

RUN update-alternatives --set python /usr/bin/python3.6
[CORP\sano2@a-2jeos6wr3a190 test2]$ docker run --name test6 -it example2:latest sh
# python
Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>> 

Ubuntu 18.04 (Python 3.7)

python3-mapnik動作おかしい

FROM ubuntu:18.04

RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y \
    python3.7 \
    python3.7-dev \
    python-pip \
    libgdal-dev \
    gdal-bin \
    libmapnik-dev \
    python3-mapnik

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10

RUN update-alternatives --set python /usr/bin/python3.7
[CORP\sano2@a-2jeos6wr3a190 test2]$ docker run --name test6 -it example2:latest sh
# python
Python 3.7.5 (default, Dec  9 2021, 17:04:37) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ModuleNotFoundError: No module named 'mapnik._mapnik'
>>> 

Ubuntu 20.04 (Python 3.8)

python3-mapnikの動作問題無し

FROM ubuntu:20.04

RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y \
    python3.8 \
    python3.8-dev \
    python3-pip \
    libgdal-dev \
    gdal-bin \
    libmapnik3.0 \
    python3-mapnik

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 10

RUN update-alternatives --set python /usr/bin/python3.8
[CORP\sano2@a-2jeos6wr3a190 test2]$ docker run --name test6 -it example2:latest sh
# python
Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>> 

Ubuntu 20.04 (Python 3.9)

python3-mapnikの動作おかしい

FROM ubuntu:20.04

RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y \
    python3.9 \
    python3.9-dev \
    python3-pip \
    libgdal-dev \
    gdal-bin \
    libmapnik3.0 \
    python3-mapnik

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 10

RUN update-alternatives --set python /usr/bin/python3.9
[CORP\sano2@a-2jeos6wr3a190 test2]$ docker run --name test6 -it example2:latest sh
# python
Python 3.9.18 (main, Aug 25 2023, 13:20:04) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ModuleNotFoundError: No module named 'mapnik._mapnik'
>>> 

Ubuntu 22.10 (Python 3.9)

python3-mapnikの動作おかしい

Ubuntu 22.04にlibmapnik3.0は無い
https://packages.ubuntu.com/search?keywords=mapnik&searchon=names

FROM docker.osgeo.org/geoserver:2.23.1

RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y \
    python3.9 \
    python3.9-dev \
    python3-pip \
    libgdal-dev \
    gdal-bin \
    libmapnik3.1 \
    python3-mapnik

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 10

RUN update-alternatives --set python /usr/bin/python3.9
[CORP\sano2@a-2jeos6wr3a190 ~]$ docker exec -it 19313b17516b sh
# python
Python 3.9.18 (main, Aug 25 2023, 13:20:14) 
[GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ModuleNotFoundError: No module named 'mapnik._mapnik'

Ubuntu 22.10 (Python 2.7)

mapnikの動作問題無し

Ubuntu 22.04にpython-mapnikは無かったのでpipでinstall
https://packages.ubuntu.com/search?keywords=mapnik&searchon=names

Dockerfile
FROM docker.osgeo.org/geoserver:2.23.1

RUN apt update
RUN apt upgrade -y
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y \
    python2.7 \
    python2.7-dev \
    python-pip \
    libgdal-dev \
    gdal-bin

RUN update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10

RUN update-alternatives --set python /usr/bin/python2.7

RUN  mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN python -m pip install -r requirements.txt

RUN python -V
RUN python -m pip freeze
requirements.txt
numpy==1.16.6
gdal==3.2.3
scikit-learn==0.20.4
shapely==1.7.1
pyproj==2.2.2
fiona==1.8.21
mapnik==0.1
# python
Python 2.7.18 (default, Jul  1 2022, 10:30:50) 
[GCC 11.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>> 

参考URL

mapnik
python-mapnik
docker-mapnik3
build_mapnik_ubuntu_22

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?