This is something that doesn’t make sense. GMT is in your pygmt environment, but the sharedir is c:/programs/gmt5/share. Do you have GMT5 installed? It seems in your Jupyter notebook, pygmt find the GMT5 library instead of the GMT6 library.
It would seem I do have GMT5 sitting there in its own “programs” directory (weirdly not Program Files). I’m not sure but I might have installed that a long time ago so it could have been sitting there messing with things. Should I uninstall GMT5? Or is there some way of redirecting the share directory to GMT6?
---------------------------------------------------------------------------
GMTCLibNotFoundError Traceback (most recent call last)
<ipython-input-3-f58669fae37f> in <module>
----> 1 import pygmt
~\Anaconda3\envs\pygmt\lib\site-packages\pygmt\__init__.py in <module>
30
31 # Start our global modern mode session
---> 32 _begin()
33 # Tell Python to run _end when shutting down
34 _atexit.register(_end)
~\Anaconda3\envs\pygmt\lib\site-packages\pygmt\session_management.py in begin()
14 """
15 prefix = "pygmt-session"
---> 16 with Session() as lib:
17 lib.call_module("begin", prefix)
18 # pygmt relies on GMT modern mode with GMT_COMPATIBILITY at version 6
~\Anaconda3\envs\pygmt\lib\site-packages\pygmt\clib\session.py in __enter__(self)
181
182 """
--> 183 self.create("pygmt-session")
184 # Need to store the version info because 'get_default' won't work after
185 # the session is destroyed.
~\Anaconda3\envs\pygmt\lib\site-packages\pygmt\clib\session.py in create(self, name)
331 pass
332
--> 333 c_create_session = self.get_libgmt_func(
334 "GMT_Create_Session",
335 argtypes=[ctp.c_char_p, ctp.c_uint, ctp.c_uint, ctp.c_void_p],
~\Anaconda3\envs\pygmt\lib\site-packages\pygmt\clib\session.py in get_libgmt_func(self, name, argtypes, restype)
282 """
283 if not hasattr(self, "_libgmt"):
--> 284 self._libgmt = load_libgmt()
285 function = getattr(self._libgmt, name)
286 if argtypes is not None:
~\Anaconda3\envs\pygmt\lib\site-packages\pygmt\clib\loading.py in load_libgmt()
44 error = err
45 if error:
---> 46 raise GMTCLibNotFoundError(
47 "Error loading the GMT shared library '{}':".format(
48 ", ".join(lib_fullnames)
GMTCLibNotFoundError: Error loading the GMT shared library 'gmt.dll, gmt_w64.dll, gmt_w32.dll':
So, there’s still a shared library problem. Can anyone help me identify the problem here?
Wow, so without changing anything after that step, import pygmt suddenly works in jupyter. I honestly haven’t changed a thing. Perhaps after the previous steps the kernel hadn’t updated. It looks to be working now.
pygmt calls ctypes.CDLL to load the shared library. If ctypes.CDLL can load the gmt library, pygmt should also be able to do that. As your pygmt now works, could your post the output of pygmt.show_versions()?
GMT or PyGMT needs Ghostscript (gswin64c) to convert PS format to other image formats. Perhaps you don’t have Ghostscript installed? You should already have installed it in your pygmt environment, but it’s unclear to me why GMT can’t find it.
You should already have installed it in your pygmt environment
Just to be clear, if I try to install Ghostscript now should I install it to the directory of my pygmt environment, or just keep to the default installation directory?
I think it means Ghostscript and GMT are not in your PATH, but GMT is in your C:/Users/taschaap/Anaconda3/envs/pygmt/Library/bin/ directory.
It’s unclear to me what Anaconda or Jupyter does on Windows. Maybe you can try to add C:/Users/taschaap/Anaconda3/envs/pygmt/Library/bin/ to your PATH. It may work, but it’s not a good solution.
Well, I have installed ghostscript with the default installation settings and pygmt is now (apparently) operational! I have even plotted a map to prove it. I am hoping that will be the end of this saga, and I thank you all for your help.