ModuleNotFoundError: No module named 'pygmt'

Hello! I’m new to both python and gmt. I installed pygmt 0.3.0 with anaconda following all instructions but when I try to import pygmt I get an error “no module named pygmt” … During the installation everything went fine, can anyone help me with this issue?.
Below is the run result in jupyter when the kernel has been changed from Python 3 to pygmt to test the program. Thank you.

ImportError                               Traceback (most recent call last)
~\anaconda3\envs\pygmt\lib\site-packages\numpy\core\ in <module>
     21 try:
---> 22     from . import multiarray
     23 except ImportError as exc:

~\anaconda3\envs\pygmt\lib\site-packages\numpy\core\ in <module>
---> 12 from . import overrides
     13 from . import _multiarray_umath

~\anaconda3\envs\pygmt\lib\site-packages\numpy\core\ in <module>
----> 7 from numpy.core._multiarray_umath import (
      8     add_docstring, implement_array_function, _get_implementing_args)

ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-f58669fae37f> in <module>
----> 1 import pygmt

~\anaconda3\envs\pygmt\lib\site-packages\pygmt\ in <module>
     14 # Import modules to make the high-level GMT Python API
---> 15 from pygmt import datasets
     16 from pygmt.figure import Figure
     17 from pygmt.modules import GMTDataArrayAccessor, config

~\anaconda3\envs\pygmt\lib\site-packages\pygmt\datasets\ in <module>
      3 # Load sample data included with GMT (downloaded from the GMT cache server).
----> 5 from pygmt.datasets.earth_relief import load_earth_relief
      6 from pygmt.datasets.tutorial import (
      7     load_japan_quakes,

~\anaconda3\envs\pygmt\lib\site-packages\pygmt\datasets\ in <module>
      5 The grids are available in various resolutions.
      6 """
----> 7 import xarray as xr
      8 from pygmt.exceptions import GMTInvalidInput
      9 from pygmt.helpers import kwargs_to_strings

~\anaconda3\envs\pygmt\lib\site-packages\xarray\ in <module>
      1 import pkg_resources
----> 3 from . import testing, tutorial, ufuncs
      4 from .backends.api import (
      5     load_dataarray,

~\anaconda3\envs\pygmt\lib\site-packages\xarray\ in <module>
      3 from typing import Hashable, Set, Union
----> 5 import numpy as np
      6 import pandas as pd

~\anaconda3\envs\pygmt\lib\site-packages\numpy\ in <module>
    143     from . import _distributor_init
--> 145     from . import core
    146     from .core import *
    147     from . import compat

~\anaconda3\envs\pygmt\lib\site-packages\numpy\core\ in <module>
     46 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
     47         __version__, exc)
---> 48     raise ImportError(msg)
     49 finally:
     50     for envkey in env_added:



Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was

We have compiled some common reasons and troubleshooting tips at:

Please note and check the following:

  * The Python version is: Python3.9 from "C:\Users\Lenovo\anaconda3\envs\pygmt\python.exe"
  * The NumPy version is: "1.20.1"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.

Hi @Richard, thanks for trying out PyGMT! I’ve encountered this issue before, and there’s a few possible reasons for the numpy error. but my first try would be to reinstall numpy as it might have been a corrupted install (at least it usually is for me). Try running the following commands in Anaconda prompt:

conda activate pygmt
conda uninstall numpy
conda clean --all  # Remove index cache, lock files, unused cache packages, and tarballs.
conda install numpy

If that doesn’t work, have a look at some of the other solutions on Let us know if you need clarification on anything.

To make it short, it means that you lacked some “dependencies” for the libraries you wanted to use. This is a common problem when installing python packages, mainly in windows. Before trying to use any kind of library, first it is suggested to look up whether it needs another library in python “family”.

The solution is to provide the python interpreter with the path-to-your-module/library. The simplest solution is to append that python path to your sys.path list. In your notebook, first try:

import sys

This isn’t a permanent change in sys.path, because when you log out, your environment is reset, so any variables you may have set are lost.

The better (and more permanent) way to solve this is to set your PYTHONPATH, which provides the interpreter with additional directories look in for python packages/modules.

from BASH type: export PYTHONPATH=/path/to/new/folder:/another/path/...../

#each path must be separated by a colon