さらいふ

ubuntuでgeopandasのインストール時に出るエラーの対処法

投稿日 : 2022/11/12 1:00:00

タグ : #SBC#arm64#Python#Ubuntu#Rock3A

warningこの記事は作成から一年以上が経過しています

最新のコードやバージョンに対応していない場合があります。ご了承ください。

筆者環境

機種 : RADXA Rock3A 8GB
OS : Ubuntu Server 20.04 (Radxa build ver 20221101-0101)

TL;DR

とりあえずこれしたら治る(pythonのバージョンは合わせてね)

sudo apt install libgdal-dev python3.x-dev gcc g++

具体的な解決ロードマップ

具体的なエラー内容

以下のようなエラーが発生した。

Collecting fiona>=1.8
  Using cached Fiona-1.8.22.tar.gz (1.4 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config'
      A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

または

Collecting fiona>=1.8
  Using cached Fiona-1.8.22.tar.gz (1.4 MB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kkrltjtl/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kkrltjtl/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-kkrltjtl/fiona/pip-egg-info
         cwd: /tmp/pip-install-kkrltjtl/fiona/
    Complete output (2 lines):
    Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config'
    A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

対処方法

以下のパッケージをダウンロードする

sudo apt install libgdal-dev

上記の対処時に以下のエラーが発生した場合

  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e2wulyso/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-e2wulyso/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-97kg8yu7
       cwd: /tmp/pip-install-e2wulyso/fiona/
  Complete output (57 lines):
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'metadata_version'
    warnings.warn(msg)
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_python'
    warnings.warn(msg)
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_external'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-3.8
  creating build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/inspector.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/collection.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/io.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/env.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/crs.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/_loading.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/rfc3339.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/transform.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/vfs.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/path.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/_show_versions.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/errors.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/__init__.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/session.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/drvsupport.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/compat.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/logutils.py -> build/lib.linux-aarch64-3.8/fiona
  creating build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/rm.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/distrib.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/env.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/dump.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/calc.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/info.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/load.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/main.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/collect.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/helpers.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/insp.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/options.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/bounds.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/cat.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/__init__.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/ls.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/filter.py -> build/lib.linux-aarch64-3.8/fiona/fio
  running build_ext
  building 'fiona.schema' extension
  creating build/temp.linux-aarch64-3.8
  creating build/temp.linux-aarch64-3.8/fiona
  aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/gdal -I/usr/include/python3.8 -c fiona/schema.c -o build/temp.linux-aarch64-3.8/fiona/schema.o
  fiona/schema.c:30:10: fatal error: Python.h: No such file or directory
     30 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for fiona
  Running setup.py clean for fiona
Successfully built shapely
Failed to build fiona
Installing collected packages: pyproj, shapely, python-dateutil, pytz, numpy, pandas, attrs, click, click-plugins, cligj, munch, fiona, pyparsing, packaging, geopandas
  WARNING: The script pyproj is installed in '/home/rock/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/home/rock/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    Running setup.py install for fiona ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e2wulyso/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-e2wulyso/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-6hbqvbac/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/rock/.local/include/python3.8/fiona
         cwd: /tmp/pip-install-e2wulyso/fiona/
    Complete output (19 lines):
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'metadata_version'
      warnings.warn(msg)
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_python'
      warnings.warn(msg)
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_external'
      warnings.warn(msg)
    running install
    running build
    running build_py
    running build_ext
    building 'fiona.schema' extension
    creating build/temp.linux-aarch64-3.8
    creating build/temp.linux-aarch64-3.8/fiona
    aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/gdal -I/usr/include/python3.8 -c fiona/schema.c -o build/temp.linux-aarch64-3.8/fiona/schema.o
    fiona/schema.c:30:10: fatal error: Python.h: No such file or directory
       30 | #include "Python.h"
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e2wulyso/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-e2wulyso/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-6hbqvbac/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/rock/.local/include/python3.8/fiona Check the logs for full command output.

まず、Pythonのバージョンを確認する

python3 -V
Python 3.8.10

そのバージョンのdevをインストールする

sudo apt install python3.x-dev

それでもエラーが治らない時

Building wheels for collected packages: fiona
  Building wheel for fiona (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kbv395hd/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kbv395hd/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-la1nq32v
       cwd: /tmp/pip-install-kbv395hd/fiona/
  Complete output (58 lines):
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'metadata_version'
    warnings.warn(msg)
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_python'
    warnings.warn(msg)
  /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_external'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-3.8
  creating build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/inspector.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/collection.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/io.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/env.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/crs.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/_loading.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/rfc3339.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/transform.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/vfs.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/path.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/_show_versions.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/errors.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/__init__.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/session.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/drvsupport.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/compat.py -> build/lib.linux-aarch64-3.8/fiona
  copying ./fiona/logutils.py -> build/lib.linux-aarch64-3.8/fiona
  creating build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/rm.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/distrib.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/env.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/dump.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/calc.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/info.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/load.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/main.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/collect.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/helpers.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/insp.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/options.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/bounds.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/cat.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/__init__.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/ls.py -> build/lib.linux-aarch64-3.8/fiona/fio
  copying ./fiona/fio/filter.py -> build/lib.linux-aarch64-3.8/fiona/fio
  running build_ext
  building 'fiona.schema' extension
  creating build/temp.linux-aarch64-3.8
  creating build/temp.linux-aarch64-3.8/fiona
  aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/gdal -I/usr/include/python3.8 -c fiona/schema.c -o build/temp.linux-aarch64-3.8/fiona/schema.o
  aarch64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-aarch64-3.8/fiona/schema.o -lgdal -o build/lib.linux-aarch64-3.8/fiona/schema.cpython-38-aarch64-linux-gnu.so
  building 'fiona._transform' extension
  aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/gdal -I/usr/include/python3.8 -c fiona/_transform.cpp -o build/temp.linux-aarch64-3.8/fiona/_transform.o -std=c++11
  aarch64-linux-gnu-gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
  compilation terminated.
  error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for fiona
  Running setup.py clean for fiona
Failed to build fiona
Installing collected packages: pyparsing, packaging, fiona, geopandas
    Running setup.py install for fiona ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kbv395hd/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kbv395hd/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tshd5ohe/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/rock/.local/include/python3.8/fiona
         cwd: /tmp/pip-install-kbv395hd/fiona/
    Complete output (17 lines):
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'metadata_version'
      warnings.warn(msg)
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_python'
      warnings.warn(msg)
    /usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'requires_external'
      warnings.warn(msg)
    running install
    running build
    running build_py
    running build_ext
    building 'fiona._transform' extension
    creating build/temp.linux-aarch64-3.8
    creating build/temp.linux-aarch64-3.8/fiona
    aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/gdal -I/usr/include/python3.8 -c fiona/_transform.cpp -o build/temp.linux-aarch64-3.8/fiona/_transform.o -std=c++11
    aarch64-linux-gnu-gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
    compilation terminated.
    error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kbv395hd/fiona/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kbv395hd/fiona/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tshd5ohe/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/rock/.local/include/python3.8/fiona Check the logs for full command output.

上記のようにerror: command 'aarch64-linux-gnu-gcc' failed with exit status 1とか言われた時はg++をインストールする。

sudo apt install g++

以上

さらだぼぉる

[非公式]滋賀県コロナまとめサイトをはじめとした滋賀情報ネットプロジェクトといった地域情報を発信する取り組みをしている。 2022年10月現在高校三年生で滋賀在住。 PythonやSvelteKitが最近のお気に入り。