Import pygmt error after jupyterlab installation

Hi All,

Using the command conda create --name pygmt --channel conda-forge pygmt, I installed the pygmt and when I import pygmt it looked fine to me.

PyGMT information:
version: v0.4.1
System information:
python: 3.9.7 | packaged by conda-forge | (default, Sep 14 2021, 01:18:03) [Clang 11.1.0 ]
executable: /Users/lli/opt/anaconda3/envs/pygmt/bin/python
machine: macOS-11.6-x86_64-i386-64bit
Dependency information:
numpy: 1.21.2
pandas: 1.3.3
xarray: 0.19.0
netCDF4: 1.5.7
packaging: 21.0
ghostscript: 9.54.0
gmt: 6.2.0
GMT library information:
binary dir: /Users/lli/opt/anaconda3/envs/pygmt/bin
cores: 8
grid layout: rows
library path: /Users/lli/opt/anaconda3/envs/pygmt/lib/libgmt.dylib
padding: 2
plugin dir: /Users/lli/opt/anaconda3/envs/pygmt/lib/gmt/plugins
share dir: /Users/lli/opt/anaconda3/envs/pygmt/share/gmt
version: 6.2.0

After jupyterlab installation with conda install jupyterlab, I am getting an ImportError. Here is the full traceback:

> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/__init__.py", line 57, in <module>
    _begin()
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/session_management.py", line 16, in begin
    with Session() as lib:
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 185, in __enter__
    self.create("pygmt-session")
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 332, in create
    c_create_session = self.get_libgmt_func(
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 284, in get_libgmt_func
    self._libgmt = load_libgmt()
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/loading.py", line 59, in load_libgmt
    raise GMTCLibNotFoundError("\n".join(error_msg))
pygmt.exceptions.GMTCLibNotFoundError: Error loading GMT shared library at '/Users/lli/opt/anaconda3/envs/pygmt/lib/libgmt.dylib'.
dlopen(/Users/lli/opt/anaconda3/envs/pygmt/lib/libgmt.dylib, 6): Symbol not found: _libiconv
  Referenced from: /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib
  Expected in: /usr/lib/libiconv.2.dylib
 in /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib
Error loading GMT shared library at 'libgmt.dylib'.
dlopen(libgmt.dylib, 6): Symbol not found: _libiconv
  Referenced from: /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib
  Expected in: /usr/lib/libiconv.2.dylib
 in /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib

Did you figure this out? I have the same problem. Thanks.

Could be a few things. Did you do conda activate pygmt before conda install jupyterlab? Just want to make sure that you installed jupyterlab into the correct virtual environment.

Otherwise, the error message you posted could be because libspatialite or libgmt got corrupted during the download or extraction process. Try doing a clean reinstall of PyGMT, like so:

conda deactivate
conda clean --all
conda create --name pygmt --channel conda-forge pygmt jupyterlab
conda activate pygmt
python -c "import pygmt; pygmt.show_versions()"
jupyter lab --no-browser

I tried installing pygmt with conda and have a somewhat similar problem with libgmt not loading. I tried doing the conda clean --all and reinstalled pygmt, but I get the same error:

python -c "import pygmt; pygmt.show_versions()"
dyld: Library not loaded: @rpath/libgeos_c.1.dylib
  Referenced from: /Users/fielding/anaconda3/envs/pygmt/lib/libgmt.6.2.0.dylib
  Reason: Incompatible library version: libgmt.6.dylib requires version 16.0.0 or later, but libgeos_c.1.dylib provides version 1.0.0
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/fielding/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/__init__.py", line 70, in <module>
    _begin()
  File "/Users/fielding/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/session_management.py", line 16, in begin
    with Session() as lib:
  File "/Users/fielding/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 183, in __enter__
    self.create("pygmt-session")
  File "/Users/fielding/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 329, in create
    c_create_session = self.get_libgmt_func(
  File "/Users/fielding/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 281, in get_libgmt_func
    self._libgmt = load_libgmt()
  File "/Users/fielding/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/loading.py", line 59, in load_libgmt
    raise GMTCLibNotFoundError("\n".join(error_msg))
pygmt.exceptions.GMTCLibNotFoundError: Error loading GMT shared library at 'libgmt.dylib'.
dlopen(libgmt.dylib, 6): Library not loaded: @rpath/libgeos_c.1.dylib
  Referenced from: /Users/fielding/anaconda3/envs/pygmt/lib/libgmt.6.2.0.dylib
  Reason: Incompatible library version: libgmt.dylib requires version 16.0.0 or later, but libgeos_c.1.dylib provides version 1.0.0

I am on a Mac running macOS 10.15.7 in case that matters.

Hi @EJFielding, yes we’re aware that there’s a problem with GEOS 3.10.0 from conda-forge on macOS (see bug report at https://github.com/GenericMappingTools/pygmt/issues/1600). Could you try downgrading to GEOS 3.9 using conda install -c conda-forge geos=3.9 and see if it works?

Edit: We’re attempting to fix this problem by rebuilding the GMT conda-forge package for GEOS 3.10.0 at https://github.com/conda-forge/gmt-feedstock/pull/169.

The problem still exists after a clean install of PyGMT.
When I remove jupyterlab, it works. It likes PyGMT can find libiconv.2.dylib in ~/anaconda3/envs/pygmt/lib, but cannot find libiconv.2.dylib in /usr/lib after jupyterlab installation.

How do I force PyGMT use this ~/anaconda3/envs/pygmt/lib/libiconv.2.dylib version?

Some additional information that may or may not be useful.
MacOS 11.6.

# packages in environment at ~/opt/anaconda3/envs/pygmt:
#
# Name                    Version                   Build  Channel
anyio                     3.3.4            py39h6e9494a_0    conda-forge
aom                       3.2.0                he49afe7_2    conda-forge
appnope                   0.1.2            py39h6e9494a_2    conda-forge
argon2-cffi               21.1.0           py39h89e85a6_0    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge
boost-cpp                 1.74.0               hff03dee_4    conda-forge
brotlipy                  0.7.0           py39h89e85a6_1001    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
c-ares                    1.18.1               h0d85af4_0    conda-forge
ca-certificates           2021.10.8            h033912b_0    conda-forge
cairo                     1.16.0            he43a7df_1008    conda-forge
certifi                   2021.10.8        py39h6e9494a_1    conda-forge
cffi                      1.14.6           py39he338e87_1    conda-forge
cfitsio                   3.470                h01dc385_7    conda-forge
cftime                    1.5.1.1          py39hc89836e_0    conda-forge
chardet                   4.0.0            py39h6e9494a_2    conda-forge
charset-normalizer        2.0.0              pyhd8ed1ab_0    conda-forge
cryptography              35.0.0           py39h209aa08_1    conda-forge
curl                      7.79.1               hf45b732_1    conda-forge
dcw-gmt                   2.0.0                h694c41f_0    conda-forge
debugpy                   1.4.1            py39h9fcab8e_0    conda-forge
decorator                 5.1.0              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
expat                     2.4.1                he49afe7_0    conda-forge
ffmpeg                    4.4.0                h79e7b16_7    conda-forge
fftw                      3.3.10          nompi_h4024a70_101    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.13.1            h10f422b_1005    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freetype                  2.10.4               h4cff582_1    conda-forge
freexl                    1.0.6                h0d85af4_0    conda-forge
fribidi                   1.0.10               hbcb3906_0    conda-forge
gdal                      3.3.3            py39he7e3f19_0    conda-forge
geos                      3.9.1                he49afe7_2    conda-forge
geotiff                   1.7.0                hb0faedc_3    conda-forge
gettext                   0.19.8.1          hd1a6beb_1008    conda-forge
ghostscript               9.54.0               he49afe7_1    conda-forge
giflib                    5.2.1                hbcb3906_2    conda-forge
glib                      2.70.0               hcf210ce_1    conda-forge
glib-tools                2.70.0               hcf210ce_1    conda-forge
gmp                       6.2.1                h2e338ed_0    conda-forge
gmt                       6.2.0                h5ea12c9_2    conda-forge
gnuplot                   5.4.1                h561275a_2    conda-forge
gnutls                    3.6.13               h756fd2b_1    conda-forge
graphicsmagick            1.3.36               hc3d8c12_0    conda-forge
graphite2                 1.3.13            h2e338ed_1001    conda-forge
gshhg-gmt                 2.3.7             h694c41f_1003    conda-forge
harfbuzz                  3.0.0                h159f659_1    conda-forge
hdf4                      4.2.15               hefd3b78_3    conda-forge
hdf5                      1.12.1          nompi_h2f0ef1a_101    conda-forge
icu                       68.2                 he49afe7_0    conda-forge
idna                      3.1                pyhd3deb0d_0    conda-forge
importlib-metadata        4.8.1            py39h6e9494a_1    conda-forge
ipykernel                 6.4.2            py39h71a6800_0    conda-forge
ipython                   7.29.0           py39h71a6800_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jbig                      2.1               h0d85af4_2003    conda-forge
jedi                      0.18.0           py39h6e9494a_3    conda-forge
jinja2                    3.0.2              pyhd8ed1ab_0    conda-forge
jpeg                      9d                   hbcb3906_0    conda-forge
json-c                    0.15                 hcb556a6_0    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.1.2              pyhd8ed1ab_0    conda-forge
jupyter_client            7.0.6              pyhd8ed1ab_0    conda-forge
jupyter_core              4.9.1            py39h6e9494a_0    conda-forge
jupyter_server            1.11.2             pyhd8ed1ab_0    conda-forge
jupyterlab                3.2.1              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         2.8.2              pyhd8ed1ab_0    conda-forge
kealib                    1.4.14               ha22a8b1_3    conda-forge
krb5                      1.19.2               hcfbf3a7_2    conda-forge
lame                      3.100             h35c211d_1001    conda-forge
lcms2                     2.12                 h577c468_0    conda-forge
lerc                      3.0                  he49afe7_0    conda-forge
libblas                   3.9.0           12_osx64_openblas    conda-forge
libcblas                  3.9.0           12_osx64_openblas    conda-forge
libclang                  11.1.0          default_he082bbe_1    conda-forge
libcurl                   7.79.1               hf45b732_1    conda-forge
libcxx                    12.0.1               habf9029_0    conda-forge
libdap4                   3.20.6               h3e144a0_2    conda-forge
libdeflate                1.8                  h0d85af4_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libev                     4.33                 haf1e3a3_1    conda-forge
libffi                    3.4.2                he49afe7_4    conda-forge
libgd                     2.3.3                h311d3fc_0    conda-forge
libgdal                   3.3.3                h053b6da_0    conda-forge
libgfortran               5.0.0           9_3_0_h6c81a4c_23    conda-forge
libgfortran5              9.3.0               h6c81a4c_23    conda-forge
libglib                   2.70.0               hf1fb8c0_1    conda-forge
libiconv                  1.16                 haf1e3a3_0    conda-forge
libkml                    1.3.0             h8fd9edb_1014    conda-forge
liblapack                 3.9.0           12_osx64_openblas    conda-forge
libllvm11                 11.1.0               hd011deb_2    conda-forge
libnetcdf                 4.8.1           nompi_h6609ca0_101    conda-forge
libnghttp2                1.43.0               h6f36284_1    conda-forge
libopenblas               0.3.18          openmp_h3351f45_0    conda-forge
libpng                    1.6.37               h7cec526_2    conda-forge
libpq                     13.3                 hea3049e_2    conda-forge
librttopo                 1.1.0                h5413771_6    conda-forge
libsodium                 1.0.18               hbcb3906_1    conda-forge
libspatialite             5.0.1                hfc891e7_9    conda-forge
libssh2                   1.10.0               h52ee1ee_2    conda-forge
libtiff                   4.3.0                hd146c10_2    conda-forge
libvpx                    1.11.0               he49afe7_3    conda-forge
libwebp                   1.2.1                h28dabe5_0    conda-forge
libwebp-base              1.2.1                h0d85af4_0    conda-forge
libxml2                   2.9.12               h93ec3fd_0    conda-forge
libzip                    1.8.0                h8b0c345_1    conda-forge
libzlib                   1.2.11            h9173be1_1013    conda-forge
llvm-openmp               12.0.1               hda6cdc1_1    conda-forge
lz4-c                     1.9.3                he49afe7_1    conda-forge
markupsafe                2.0.1            py39h89e85a6_0    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py39h89e85a6_1004    conda-forge
mysql-common              8.0.27               h694c41f_1    conda-forge
mysql-libs                8.0.27               h115446f_1    conda-forge
nbclassic                 0.3.4              pyhd8ed1ab_0    conda-forge
nbclient                  0.5.4              pyhd8ed1ab_0    conda-forge
nbconvert                 6.2.0            py39h6e9494a_0    conda-forge
nbformat                  5.1.3              pyhd8ed1ab_0    conda-forge
ncurses                   6.2                  h2e338ed_4    conda-forge
nest-asyncio              1.5.1              pyhd8ed1ab_0    conda-forge
netcdf4                   1.5.8           nompi_py39he7d1c46_100    conda-forge
nettle                    3.6                  hedd7734_0    conda-forge
notebook                  6.4.5              pyha770c72_0    conda-forge
nspr                      4.32                 hcd9eead_0    conda-forge
nss                       3.71                 h31e2bf1_0    conda-forge
numpy                     1.21.3           py39h7eed0ac_0    conda-forge
openh264                  2.1.1                hfd3ada9_0    conda-forge
openjpeg                  2.4.0                h6e7aa92_1    conda-forge
openssl                   1.1.1l               h0d85af4_0    conda-forge
packaging                 21.0               pyhd8ed1ab_0    conda-forge
pandas                    1.3.4            py39h4d6be9b_0    conda-forge
pandoc                    2.16                 h0d85af4_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
pango                     1.48.10              h056538c_2    conda-forge
parso                     0.8.2              pyhd8ed1ab_0    conda-forge
pcre                      8.45                 he49afe7_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       21.3.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               hbcb3906_0    conda-forge
poppler                   21.09.0              h9573804_3    conda-forge
poppler-data              0.4.11               hd8ed1ab_0    conda-forge
postgresql                13.3                 he8fe76e_2    conda-forge
proj                      8.1.1                h1512c50_2    conda-forge
prometheus_client         0.12.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.21             pyha770c72_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.10.0             pyhd8ed1ab_0    conda-forge
pygmt                     0.5.0              pyhd8ed1ab_1    conda-forge
pyopenssl                 21.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.4              pyhd8ed1ab_0    conda-forge
pyrsistent                0.17.3           py39h89e85a6_2    conda-forge
pysocks                   1.7.1            py39h6e9494a_3    conda-forge
python                    3.9.7           h1248fe1_3_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2021.3             pyhd8ed1ab_0    conda-forge
pyzmq                     22.3.0           py39h7fec2f1_0    conda-forge
qt                        5.12.9               h126340a_4    conda-forge
readline                  8.1                  h05e3726_0    conda-forge
requests                  2.26.0             pyhd8ed1ab_0    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                58.4.0           py39h6e9494a_1    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.2.0            py39h6e9494a_1    conda-forge
sqlite                    3.36.0               h23a322b_2    conda-forge
svt-av1                   0.8.7                he49afe7_1    conda-forge
terminado                 0.12.1           py39h6e9494a_0    conda-forge
testpath                  0.5.0              pyhd8ed1ab_0    conda-forge
tiledb                    2.3.4                h8370e7a_0    conda-forge
tk                        8.6.11               h5dbffcc_1    conda-forge
tornado                   6.1              py39h89e85a6_2    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
tzcode                    2021e                h0d85af4_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
urllib3                   1.26.7             pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          0.57.0           py39h6e9494a_4    conda-forge
wheel                     0.37.0             pyhd8ed1ab_1    conda-forge
x264                      1!161.3030           h0d85af4_1    conda-forge
x265                      3.5                  h940c156_1    conda-forge
xarray                    0.19.0             pyhd8ed1ab_1    conda-forge
xerces-c                  3.2.3                h379762d_3    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zeromq                    4.3.4                he49afe7_1    conda-forge
zipp                      3.6.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h9173be1_1013    conda-forge
zstd                      1.5.0                h582d3a0_0    conda-forge

Hi @kradori. could you post the full error that you are getting with libiconv.2.dylib not found? Also, just to clarify, PyGMT/GMT should not be picking up libiconv.2.dylib from /usr/lib, it should be using the ~/anaconda3/envs/pygmt/lib/libiconv.2.dylib (as you probably know already).

My guess is that your jupyterlab was installed outside of the pygmt virtual environment, but just to be sure, can you try the following (adapted from No module issue when importing pygmt):

conda env remove -n pygmt
conda clean --all

conda create --name pygmt --channel conda-forge pygmt jupyterlab
conda activate pygmt

jupyterlab --no-browser

This should install jupyterlab inside the pygmt virtual environment. Given that this is a recurring issue with people using jupyter and pygmt, we might try to clarify this on the installation page.

Hi, @weiji14.

I do not think this is a virtual environment problem. I installed jupyter in PyGMT environment.
The import error occurred only after jupyter installation (not import PyGMT error in jupyter).

If I install PyGMT without jupyterlab,

conda env remove -n pygmt
conda clean --all
conda create --name pygmt --channel conda-forge pygmt geos=3.9
conda activate pygmt
python -c "import pygmt; pygmt.show_versions()"

It works.

  version: v0.5.0
System information:
  python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18)  [Clang 11.1.0 ]
  executable: /Users/lli/opt/anaconda3/envs/pygmt/bin/python
  machine: macOS-11.6-x86_64-i386-64bit
Dependency information:
  numpy: 1.21.3
  pandas: 1.3.4
  xarray: 0.19.0
  netCDF4: 1.5.8
  packaging: 21.0
  ghostscript: 9.54.0
  gmt: 6.2.0
GMT library information:
  binary dir: /Users/lli/opt/anaconda3/envs/pygmt/bin
  cores: 8
  grid layout: rows
  library path: /Users/lli/opt/anaconda3/envs/pygmt/lib/libgmt.dylib
  padding: 2
  plugin dir: /Users/lli/opt/anaconda3/envs/pygmt/lib/gmt/plugins
  share dir: /Users/lli/opt/anaconda3/envs/pygmt/share/gmt
  version: 6.2.0

If I install PyGMT with jupyterlab,

conda env remove -n pygmt
conda clean --all
conda create --name pygmt --channel conda-forge pygmt geos=3.9  jupyterlab
conda activate pygmt
python -c "import pygmt; pygmt.show_versions()"

This is the error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/__init__.py", line 57, in <module>
    _begin()
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/session_management.py", line 16, in begin
    with Session() as lib:
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 185, in __enter__
    self.create("pygmt-session")
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 332, in create
    c_create_session = self.get_libgmt_func(
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/session.py", line 284, in get_libgmt_func
    self._libgmt = load_libgmt()
  File "/Users/lli/opt/anaconda3/envs/pygmt/lib/python3.9/site-packages/pygmt/clib/loading.py", line 59, in load_libgmt
    raise GMTCLibNotFoundError("\n".join(error_msg))
pygmt.exceptions.GMTCLibNotFoundError: Error loading GMT shared library at '/Users/lli/opt/anaconda3/envs/pygmt/lib/libgmt.dylib'.
dlopen(/Users/lli/opt/anaconda3/envs/pygmt/lib/libgmt.dylib, 6): Symbol not found: _libiconv
  Referenced from: /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib
  Expected in: /usr/lib/libiconv.2.dylib
 in /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib
Error loading GMT shared library at 'libgmt.dylib'.
dlopen(libgmt.dylib, 6): Symbol not found: _libiconv
  Referenced from: /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib
  Expected in: /usr/lib/libiconv.2.dylib
 in /Users/lli/opt/anaconda3/envs/pygmt/lib/libspatialite.7.dylib

Hmm, you might be on to another dependency related bug. Unfortunately I don’t have a macOS computer to reproduce this. @maxrjones could you test and see if the same libiconv error appears?

Oh and btw everyone, we fixed the GEOS 3.10 issue, so no need to pin to GEOS 3.9 anymore.

No, I am not able to reproduce this error on macOS.

For my installations, libspatialite.7.dylib references libiconv.2.dylib in the same /opt/anaconda3/env/pygmt/lib/ directory, not /usr/lib/. I’m not sure what about the jupterlab installation is breaking the reference.

FYI. I try to install PyGMT on another MAC and can not reproduce my issue on MacOS 10.15.6. It seems to potentially occur on MacOS 11.6.

I am also on MacOS 11.6 and did not receive the same error. This particular issue is often unique to specific environments and difficult to reproduce (e.g., https://newbedev.com/libiconv-or-iconv-undefined-symbol-on-mac-osx).

I waited until the dust settled and I ran conda update gmt today. It updated a lot of packages. Now PyGMT runs on my Mac!

PyGMT information:
  version: v0.5.0
System information:
  python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18)  [Clang 11.1.0 ]
  executable: /Users/fielding/anaconda3/envs/pygmt/bin/python
  machine: macOS-10.15.7-x86_64-i386-64bit
Dependency information:
  numpy: 1.21.3
  pandas: 1.3.4
  xarray: 0.19.0
  netCDF4: 1.5.8
  packaging: 21.0
  ghostscript: 9.54.0
  gmt: 6.2.0
GMT library information:
  binary dir: /Users/fielding/anaconda3/envs/pygmt/bin
  cores: 16
  grid layout: rows
  library path: /Users/fielding/anaconda3/envs/pygmt/lib/libgmt.dylib
  padding: 2
  plugin dir: /Users/fielding/anaconda3/envs/pygmt/lib/gmt/plugins
  share dir: /Users/fielding/anaconda3/envs/pygmt/share/gmt
  version: 6.2.0
1 Like