PyGMT can't load GMT library for Python 3.8 + Windows 10

See original GitHub issue

Description of the problem despite adding to path set "GMT_LIBRARY_PATH=C:\programs\gmt6\lib"

import pygmt
pygmt.show_versions()
pygmt.test()

---------------------------------------------------------------------------
GMTCLibNotFoundError                      Traceback (most recent call last)
<ipython-input-2-9f7fe29d69d2> in <module>
----> 1 import pygmt
      2 pygmt.show_versions()
      3 pygmt.test()

c:\program files\python38\lib\site-packages\pygmt\__init__.py in <module>
     55 
     56 # Start our global modern mode session
---> 57 _begin()
     58 # Tell Python to run _end when shutting down
     59 _atexit.register(_end)

c:\program files\python38\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

c:\program files\python38\lib\site-packages\pygmt\clib\session.py in __enter__(self)
    183             raising the exception.
    184         """
--> 185         self.create("pygmt-session")
    186         # Need to store the version info because 'get_default' won't work after
    187         # the session is destroyed.

c:\program files\python38\lib\site-packages\pygmt\clib\session.py in create(self, name)
    330             pass
    331 
--> 332         c_create_session = self.get_libgmt_func(
    333             "GMT_Create_Session",
    334             argtypes=[ctp.c_char_p, ctp.c_uint, ctp.c_uint, ctp.c_void_p],

c:\program files\python38\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:

c:\program files\python38\lib\site-packages\pygmt\clib\loading.py in load_libgmt(lib_fullnames)
     57 
     58     if error:
---> 59         raise GMTCLibNotFoundError("\n".join(error_msg))
     60 
     61     return libgmt

GMTCLibNotFoundError: Error loading GMT shared library at 'gmt.dll'.

System information

python -c "import pygmt; pygmt.show_versions()":

  File "<string>", line 1, in <module>
  File "C:\Program Files\Python38\lib\site-packages\pygmt\__init__.py", line 57, in <module>
    _begin()
  File "C:\Program Files\Python38\lib\site-packages\pygmt\session_management.py", line 16, in begin
    with Session() as lib:
  File "C:\Program Files\Python38\lib\site-packages\pygmt\clib\session.py", line 185, in __enter__
    self.create("pygmt-session")
  File "C:\Program Files\Python38\lib\site-packages\pygmt\clib\session.py", line 332, in create
    c_create_session = self.get_libgmt_func(
  File "C:\Program Files\Python38\lib\site-packages\pygmt\clib\session.py", line 284, in get_libgmt_func
    self._libgmt = load_libgmt()
  File "C:\Program Files\Python38\lib\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 'gmt.dll'.
Could not find module 'gmt.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Error loading GMT shared library at 'gmt_w64.dll'.
Could not find module 'gmt_w64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Error loading GMT shared library at 'gmt_w32.dll'.
Could not find module 'gmt_w32.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Python 3.8.2 + Windows 10 I used pip3 install pygmt , I have not tried yet pip install --pre --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pygmt as I read that you decided not to compile for Py3.8 anymore

I experienced bugs using “outdated” modules and dependency troubles with py3.9, as it was too fresh…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pertetotalecommented, Aug 28, 2021

import pygmt pygmt.show_versions() #pygmt.test() > gave a simple error btw

PyGMT information: version: v0.4.1 System information: python: 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] executable: c:\program files\python38\python.exe machine: Windows-10-10.0.19041-SP0

GMT works now Thanks!

1reaction
seismancommented, Aug 27, 2021

as I read that you decided not to compile for Py3.8 anymore

I’m not sure what you meant here. PyGMT should support Python>=3.7.

despite adding to path set “GMT_LIBRARY_PATH=C:\programs\gmt6\lib”

Can you try setting GMT_LIBRARY_PATH to C:\programs\gmt6\bin instead?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing - PyGMT
PyGMT is tested to run on Python 3.8 or greater. ... Compiled conda packages of GMT for Linux, macOS and Windows are provided...
Read more >
PyGMT can't load GMT library for Python 3.6 + Windows #693
Description of the problem It seems PyGMT can't correctly find GMT for Python 3.6 + Windows. The error messages are: pygmt.exceptions.
Read more >
Getting pygmt running in Jupyter - GMT Community Forum
Hi all, I'm just having some trouble importing pygmt in jupyter. ... System information: python: 3.8.6 | packaged by conda-forge | (default, ...
Read more >
PyGMT: A Python interface for the Generic Mapping Tools
Goal: We are bringing the power of GMT to Python through a wrapper library that relies on the GMT C API. Find out...
Read more >
pygmt · PyPI
Build a Pythonic API for GMT. Interface with the GMT C API directly using ctypes (no system calls). Support for rich display in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found