LoginSignup
1
0

More than 1 year has passed since last update.

pipでpygmtをインストール

Last updated at Posted at 2022-05-03

はじめに

PyGMTはanaconda環境で使うことが推奨されているが、pipでもインストールすることができる。
しかし、pipでインストールしたのみでは、エラーが発生するのでその解決方法を解説する。

インストール環境

  • Ubuntu 22.04
  • Python 3.10
  • GMT 6.3.0(aptでインストール)

pipでインストール

ドキュメントにある通りに実行する。

pip3 install pygmt

記事執筆時(2022/5/3)ではPyGMT 0.6.1がインストールされた。PyGMTはバージョンにより、対応するPythonとGMTのバージョンが異なるので、注意すること。(リンク

PyGMTをimportするとエラーが発生する。

import pygmt

エラー内容

pygmt.exceptions.GMTCLibNotFoundError: Error loading GMT shared library at 'libgmt.so'.
libgmt.so: cannot open shared object file: No such file or directory

解決方法

libgmt.soの場所を確認する。

$ gmt --show-library
/usr/lib/x86_64-linux-gnu/libgmt.so

libgmt.soの名前を確認する。

$ ls /usr/lib/x86_64-linux-gnu/libgmt*
/usr/lib/x86_64-linux-gnu/libgmt.so.6  /usr/lib/x86_64-linux-gnu/libgmt.so.6.3.0

名前が異なる場合はシンボリックリンクを作成する。

$ cd /usr/lib/x86_64-linux-gnu
$ sudo ln -s libgmt.so.6 libgmt.so

環境変数を設定する。

export GMT_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu

.bashrcなどに書き込むと良い。

動作確認

import pygmt
pygmt.show_versions()

これで情報が表示されればOK。

1
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
1
0