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
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:
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?
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.
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):
This should install jupyterlabinside 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.
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).
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.