Pygmt cannot be upgraded to the latest version

Hi everyone, I am new to PyGmt, I installed pyGmt with conda today, but the version number is 0.3, I found the latest version is 0.6. I also tried to update pygmt with conda update -c conda-forge pygmt, but the updated version is still 0.3. How can I upgrade to the latest version, thanks a lot.
The version information is as follows.
>>> pygmt.show_versions()
PyGMT information:
version: v0.3.1
System information:
python: 3.9.12 (main, Apr 5 2022, 06:56:58) [GCC 7.5.0]
executable: miniconda3/bin/python
machine: Linux-5.13.0-27-lowlatency-x86_64-with-glibc2.31
Dependency information:
numpy: 1.22.4
pandas: 1.4.2
xarray: 2022.3.0
netCDF4: 1.5.6
packaging: 21.3
ghostscript: 9.54.0
gmt: 6.1.1
GMT library information:
version: 6.1.1

Hmm, could you try conda install -c conda-forge pygmt=0.6.1?

If that doesn’t work, try copying and pastng the output message you get, or show us the output of conda list. Maybe you have a dependency that is in conflict with higher pygmt versions.

thanks a lot, it works

Can I update my previously installed pygmt? Suppose I’ve installed 0.7 version but now 0.9 is available. How can I update it?

Hello @lalit.seismo,

please see the documentation at https://www.pygmt.org/latest/install.html#using-mamba-conda-recommended to upgrade to the latest stable release.

1 Like

I am also having troubling updating to v0.9.0 from pygmt v0.7.0 (build: pyhd8ed1ab_0, channel: conda-forge).

I tried “conda activate pygmt” then “conda update pygmt” and it gives the message:
" Collecting package metadata (current_repodata.json): done
Solving environment: done
All requested packages already installed."

So I tried uninstalling and reinstalling pygmt from my computer using the work-around @weiji14 suggested.
“conda install -c conda-forge pygmt=0.9.0”

But I get the following error. The same error is given if I try to update to v0.8.0.

"+Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • pygmt=0.9.0

Current channels:

Please advise if you see what could be going wrong! Thank you!

Actually, looking at the versions on anaconda.org, I am guessing the issue is because the latest two versions are .conda files when previous versions were .tar.bz2 files. But if anyone has had success updating their conda environment using these new versions I would appreciate their insight! For reference, I am running macOS Ventura. Thanks!

Could you post the output of running conda info? It might be that you’ll need to update your conda version and/or GMT version too. Are you running with Intel or Arm (M1) chips?

packages in environment at /Users/arleaman/anaconda3/envs/pygmt:

Name Version Build Channel

blosc 1.21.4 heccf04b_0 conda-forge
boost-cpp 1.74.0 h8b082ac_8 conda-forge
bzip2 1.0.8 h0d85af4_4 conda-forge
c-ares 1.19.1 h0dc2134_0 conda-forge
ca-certificates 2023.7.22 h8857fd0_0 conda-forge
cairo 1.16.0 h1680b09_1011 conda-forge
cfitsio 4.1.0 h2c97ad1_0 conda-forge
cftime 1.6.2 py310h936d966_1 conda-forge
curl 7.86.0 h581aaea_0 conda-forge
dcw-gmt 2.1.1 h694c41f_0 conda-forge
expat 2.5.0 hf0c8a7f_1 conda-forge
fftw 3.3.10 nompi_h4fa670e_108 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.14.2 h5bb23bf_0 conda-forge
fonts-conda-ecosystem 1 0 conda-forge
fonts-conda-forge 1 0 conda-forge
freetype 2.12.1 h3f81eb7_1 conda-forge
freexl 1.0.6 hb7f2c08_1 conda-forge
gdal 3.5.0 pypi_0 pypi
geos 3.10.3 hb486fe8_0 conda-forge
geotiff 1.7.1 had63758_1 conda-forge
gettext 0.19.8.1 hd1a6beb_1008 conda-forge
ghostscript 9.54.0 h96cf925_2 conda-forge
giflib 5.2.1 hb7f2c08_3 conda-forge
gmt 6.3.0 hde71ec8_6 conda-forge
gshhg-gmt 2.3.7 h694c41f_1003 conda-forge
hdf4 4.2.15 h0623a88_4 conda-forge
hdf5 1.12.1 nompi_h0aa1fa2_104 conda-forge
icu 70.1 h96cf925_0 conda-forge
jpeg 9e hac89ed1_2 conda-forge
json-c 0.16 h01d06f9_0 conda-forge
kealib 1.4.14 h4dab1bc_4 conda-forge
krb5 1.19.3 hb98e516_0 conda-forge
lcms2 2.12 h577c468_0 conda-forge
lerc 4.0.0 hb486fe8_0 conda-forge
libblas 3.9.0 17_osx64_openblas conda-forge
libcblas 3.9.0 17_osx64_openblas conda-forge
libcurl 7.86.0 h581aaea_0 conda-forge
libcxx 16.0.6 hd57cbcb_0 conda-forge
libdap4 3.20.6 h3e144a0_2 conda-forge
libdeflate 1.14 hb7f2c08_0 conda-forge
libedit 3.1.20210910 hca72f7f_0
libev 4.33 haf1e3a3_1 conda-forge
libexpat 2.5.0 hf0c8a7f_1 conda-forge
libffi 3.4.2 h0d85af4_5 conda-forge
libgdal 3.5.0 h0a9d91c_3 conda-forge
libgfortran 5.0.0 11_3_0_h97931a8_31 conda-forge
libgfortran5 12.2.0 he409387_31 conda-forge
libglib 2.70.2 hf1fb8c0_4 conda-forge
libiconv 1.16 haf1e3a3_0 conda-forge
libkml 1.3.0 h8fd9edb_1014 conda-forge
liblapack 3.9.0 17_osx64_openblas conda-forge
libnetcdf 4.8.1 nompi_h6609ca0_102 conda-forge
libnghttp2 1.52.0 he2ab024_0 conda-forge
libopenblas 0.3.23 openmp_h429af6e_0 conda-forge
libpng 1.6.39 ha978bb4_0 conda-forge
libpq 14.3 h2b7167c_0 conda-forge
librttopo 1.1.0 h52bd064_10 conda-forge
libspatialite 5.0.1 hc4f8150_16 conda-forge
libsqlite 3.42.0 h58db7d2_0 conda-forge
libssh2 1.11.0 hd019ec5_0 conda-forge
libtiff 4.4.0 hdb44e8a_4 conda-forge
libwebp-base 1.3.0 hb7f2c08_0 conda-forge
libxml2 2.9.14 h08a9926_0 conda-forge
libzip 1.9.2 h6db710c_1 conda-forge
libzlib 1.2.13 h8a1eda9_5 conda-forge
llvm-openmp 16.0.6 hff08bdf_0 conda-forge
lz4-c 1.9.4 hf0c8a7f_0 conda-forge
ncurses 6.4 hf0c8a7f_0 conda-forge
netcdf4 1.5.8 nompi_py310h1579a17_101 conda-forge
nspr 4.35 hea0b92c_0 conda-forge
nss 3.89 h78b00b3_0 conda-forge
numpy 1.24.2 py310h788a5b3_0 conda-forge
openjpeg 2.4.0 h6e7aa92_1 conda-forge
openssl 3.1.1 h8a1eda9_1 conda-forge
packaging 23.0 pyhd8ed1ab_0 conda-forge
pandas 1.5.1 py310hecf8f37_1 conda-forge
pcre 8.45 he49afe7_0 conda-forge
pip 23.1.2 pyhd8ed1ab_0 conda-forge
pixman 0.40.0 hbcb3906_0 conda-forge
poppler 22.04.0 hed6754a_1 conda-forge
poppler-data 0.4.12 hd8ed1ab_0 conda-forge
postgresql 14.3 hd3ec586_0 conda-forge
proj 9.0.0 h2364a93_1 conda-forge
pygmt 0.7.0 pyhd8ed1ab_0 conda-forge
python 3.10.10 he7542f4_0_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python_abi 3.10 3_cp310 conda-forge
pytz 2022.5 pyhd8ed1ab_0 conda-forge
readline 8.2 h9e318b2_1 conda-forge
setuptools 67.7.2 pyhd8ed1ab_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
snappy 1.1.10 h225ccf5_0 conda-forge
sqlite 3.42.0 h2b0dec6_0 conda-forge
tiledb 2.9.3 h86bd37b_0 conda-forge
tk 8.6.12 h5dbffcc_0 conda-forge
tzcode 2023c hb7f2c08_0 conda-forge
tzdata 2023c h71feb2d_0 conda-forge
wheel 0.40.0 pyhd8ed1ab_0 conda-forge
xarray 2022.10.0 pyhd8ed1ab_0 conda-forge
xerces-c 3.2.4 h2007e90_1 conda-forge
xz 5.2.6 h775f41a_0 conda-forge
zlib 1.2.13 h8a1eda9_5 conda-forge
zstd 1.5.2 hbc0c0cd_6 conda-forge

@weiji14 it’s an M1 chip

And this is my conda version.

      conda version : 22.9.0
conda-build version : 3.21.4
     python version : 3.8.8.final.0
   virtual packages : __osx=10.16=0
                      __unix=0=0
                      __archspec=1=x86_64
           platform : osx-64
         user-agent : conda/22.9.0 requests/2.25.1 CPython/3.8.8 Darwin/22.2.0 OSX/10.16

Hmm, could you try conda update -n base conda to get a newer version of conda (23.x.x)? After that, try to uninstall gdal (which is from pypi and not conda-forge?), gmt and pygmt, and then reinstall with conda install -c conda-forge pygmt (which should pull in gmt as well).

If that doesn’t work you might need to delete your conda environment using conda env remove -n name-of-your-env and reinstall from scratch. This sounds like one of those funny dependency conflicts with outdated gdal/geos/proj versions that requires almost a clean install to fix unfortunately. Since you have an M1 chip, you might benefit from a clean install to get the osx-arm64 packages anyway, because it looks like you’re using the classic osx-64 packages now. Not sure if you’ll need to reinstall with the osx-arm64 version anaconda for that though.

@weiji14 I had to remove anaconda3 from my device to upgrade to the osx-arm64 version. I now have current conda and python versions, but I am still encountering the same issue. I am unable to install pygmt or gmt packages. I am able to install other packages, such as jupyterlab using “conda install -c conda-forge jupyterlab”, so I’m not sure what could be going wrong.

active environment : pygmt
active env location : /Users/arleaman/anaconda3/envs/pygmt
shell level : 2
user config file : /Users/arleaman/.condarc
populated config files : /Users/arleaman/.condarc
conda version : 23.7.2
conda-build version : 3.26.0
python version : 3.11.4.final.0
virtual packages : __archspec=1=arm64
__osx=13.1=0
__unix=0=0
base environment : /Users/arleaman/anaconda3 (writable)
conda av data dir : /Users/arleaman/anaconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64 (offline)
https://repo.anaconda.com/pkgs/main/noarch (offline)
https://repo.anaconda.com/pkgs/r/osx-arm64 (offline)
https://repo.anaconda.com/pkgs/r/noarch (offline)
https://conda.anaconda.org/conda-forge/osx-arm64 (offline)
https://conda.anaconda.org/conda-forge/noarch (offline)
package cache : /Users/arleaman/anaconda3/pkgs
/Users/arleaman/.conda/pkgs
envs directories : /Users/arleaman/anaconda3/envs
/Users/arleaman/.conda/envs
platform : osx-arm64
user-agent : conda/23.7.2 requests/2.31.0 CPython/3.11.4 Darwin/22.2.0 OSX/13.1
UID:GID : 501:20
netrc file : None
offline mode : True

(pygmt) arleaman@MacBook-Pro-2 ~ % conda install -c conda-forge pygmt
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • pygmt

Current channels:

To search for alternate channels that may provide the conda package you’re
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.

@weiji14 after a very painful day, I realized that my conda was in offline mode. I have successfully updated PyGMT now…

Thank you for all your help!

1 Like

Owh, I didn’t even realize conda had an offline mode! Glad that you managed to install pygmt in the end, and hope that the osx-arm64 package optimized for M1 chips is worth it!

1 Like

Hi Weiji14, I am new to use pygmt but I have successfully installed it and launched it using conda. but when I am trying to mimport the pygmt from the jupyter notebook it is showing an error message. thank you

GMTCLibNotFoundError                      Traceback (most recent call last)
Cell In[1], line 1
----> 1 import pygmt
      2 pygmt.show_versions()
      4 fig = pygmt.Figure()

File ~\anaconda3\lib\site-packages\pygmt\__init__.py:29
     27 __version__ = f'v{version("pygmt")}'  # e.g. v0.1.2.dev3+g0ab3cd78
     28 __commit__ = __version__.split("+g")[-1] if "+g" in __version__ else ""  # 0ab3cd78
---> 29 with clib.Session() as lib:
     30     __gmt_version__ = lib.info["version"]
     32 # Import modules to make the high-level GMT Python API

File ~\anaconda3\lib\site-packages\pygmt\clib\session.py:217, in Session.__enter__(self)
    204 def __enter__(self):
    205     """
    206     Create a GMT API session and check the libgmt version.
    207 
   (...)
    215         raising the exception.
    216     """
--> 217     self.create("pygmt-session")
    218     # Need to store the version info because 'get_default' won't work after
    219     # the session is destroyed.
    220     version = self.info["version"]

File ~\anaconda3\lib\site-packages\pygmt\clib\session.py:364, in Session.create(self, name)
    361 except GMTCLibNoSessionError:
    362     pass
--> 364 c_create_session = self.get_libgmt_func(
    365     "GMT_Create_Session",
    366     argtypes=[ctp.c_char_p, ctp.c_uint, ctp.c_uint, ctp.c_void_p],
    367     restype=ctp.c_void_p,
    368 )
    370 # Capture the output printed by GMT into this list. Will use it later
    371 # to generate error messages for the exceptions raised by API calls.
    372 self._error_log = []  # pylint: disable=attribute-defined-outside-init

File ~\anaconda3\lib\site-packages\pygmt\clib\session.py:316, in Session.get_libgmt_func(self, name, argtypes, restype)
    279 """
    280 Get a ctypes function from the libgmt shared library.
    281 
   (...)
    312 <class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>
    313 """
    314 if not hasattr(self, "_libgmt"):
    315     # pylint: disable=attribute-defined-outside-init
--> 316     self._libgmt = load_libgmt()
    317 function = getattr(self._libgmt, name)
    318 if argtypes is not None:

File ~\anaconda3\lib\site-packages\pygmt\clib\loading.py:59, in load_libgmt(lib_fullnames)
     56         failing_libs.append(libname)
     58 if error:
---> 59     raise GMTCLibNotFoundError("\n".join(error_msg))
     61 return libgmt

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.

Hi @Rabiu, the error message indicates that you might have installed pygmt without gmt somehow. Could you do a conda activate pygmt && conda install gmt and then try importing again?

Thank you so much for the reply Weiji14,
I have done what you asked me to do but the problem is still repeating as you can see. thank you

It’s likely that the GMT package is installed in your “pygmt” environment, but your Jupyter is running the PyGMT in the “base” environment.

@seiman, thank you so much for the information. so how can i fixed the problem?